|
Anyone have experience with Project Reactor and Netty? I'm trying to write a proxy that can do streaming decryption + download of large files to avoid buffering them. Netty's HTTP client gives me a Flux of ByteBuf's of arbitrary size and I need to turn that into a Flux of byte[]'s of a fixed size for decryption. Not sure what operation I'm looking for - it needs to consume every ByteBuf like map(), but each input could result in 0-N outputs. This is my first foray into reactive programming, so I might be missing something simple.
|
# ? Apr 13, 2020 22:30 |
|
|
# ? Apr 26, 2024 02:24 |
|
Pedestrian Xing posted:Anyone have experience with Project Reactor and Netty? I'm trying to write a proxy that can do streaming decryption + download of large files to avoid buffering them. Netty's HTTP client gives me a Flux of ByteBuf's of arbitrary size and I need to turn that into a Flux of byte[]'s of a fixed size for decryption. Not sure what operation I'm looking for - it needs to consume every ByteBuf like map(), but each input could result in 0-N outputs. This is my first foray into reactive programming, so I might be missing something simple. No but I have experience with Netty, and I'd just use a Pipeline to decrypt the stream before it got to Project Reactor, unless you must use their encryption.
|
# ? Apr 14, 2020 02:09 |
|
Pedestrian Xing posted:Anyone have experience with Project Reactor and Netty? I'm trying to write a proxy that can do streaming decryption + download of large files to avoid buffering them. Netty's HTTP client gives me a Flux of ByteBuf's of arbitrary size and I need to turn that into a Flux of byte[]'s of a fixed size for decryption. Not sure what operation I'm looking for - it needs to consume every ByteBuf like map(), but each input could result in 0-N outputs. This is my first foray into reactive programming, so I might be missing something simple. I did finally figure this out, the answer is Flux<T>'s flatMapConcurrent(Function<T, Flux<T>>) method. It has to return a Flux, but it can have 0..N members. Hughlander posted:No but I have experience with Netty, and I'd just use a Pipeline to decrypt the stream before it got to Project Reactor, unless you must use their encryption. Thanks, I did look into this. Ultimately, since I'm building on Spring Cloud Gateway, I'm not the one constructing the HTTPClient and processing the output separately seemed easier.
|
# ? Apr 15, 2020 04:06 |
|
word has come down from high at work that our dev team will probably start having to do some Java work soonish. I have zero Java experience, can anyone recommend resources/courses for getting started? the link in the second post here is a bit old so not sure if there's something more recent to look for. there's a few of those monolithic 70 hour courses on Udemy of course. for context I am a dirty front-end developer who writes mostly JavaScript and has a good amount of PHP experience. thanks!
|
# ? Apr 15, 2020 20:50 |
|
my bony fealty posted:word has come down from high at work that our dev team will probably start having to do some Java work soonish. I have zero Java experience, can anyone recommend resources/courses for getting started? the link in the second post here is a bit old so not sure if there's something more recent to look for. there's a few of those monolithic 70 hour courses on Udemy of course. Effective Java is your best bet for getting the language basics down. The thing to understand about Java is it is very old and depending on which version of Java you can code to you will have wildly nicer and more modern options for things like threads, file interactions, etc. You can do all that basically back to Java 1 but it gets more annoying the further back you go. If something feels fiddly as poo poo there is a very good chance there is a better and more modern way to do it and whatever documentation/stackoverflow you were looking at is out of date. Some recommendations I can really make about Java coming from other languages is it has some of the finest tooling chains of any language in existence. I know people who insist on writing Java in Vim/Emacs/Notepad; those people are loving lunatics and you should not listen to them. 1) Find an IDE you like and learn the IDE's functions. I see a lot of people using the IDE like a really heavyweight text editor which is missing the point badly. 2) Learn the Java syntax, notice this is #2! 3) Start learning about the debugging and profiling tools. Flight Recorder and VisualVM are both free and get you 90% of some of the best tools around for that poo poo. Objective Action fucked around with this message at 03:40 on Apr 16, 2020 |
# ? Apr 16, 2020 03:38 |
Objective Action posted:1) Find an IDE you like and learn the IDE's functions. I see a lot of people using the IDE like a really heavyweight text editor which is missing the point badly. I wouldn't really agree with this, most IDE functions don't make sense until you've used the language more. For a free IDE, I'd say VSCode (never used it but I don't think I'll ever voluntarily recommend eclipse again). If you're allowed a bit of IDE budget (or if you already have licenses for frontend work) pick up IntelliJ IDEA. I'm pretty sure these both have the added benefit of having modules for your frontend work as well as java.
|
|
# ? Apr 16, 2020 14:15 |
|
ChickenWing posted:I wouldn't really agree with this, most IDE functions don't make sense until you've used the language more. For a free IDE, I'd say VSCode (never used it but I don't think I'll ever voluntarily recommend eclipse again). If you're allowed a bit of IDE budget (or if you already have licenses for frontend work) pick up IntelliJ IDEA. I'm pretty sure these both have the added benefit of having modules for your frontend work as well as java. IntelliJ IDEA Community Edition is free and quite full featured, I'd recommend that ahead of VSCode for Java.
|
# ? Apr 16, 2020 18:16 |
|
carry on then posted:IntelliJ IDEA Community Edition is free and quite full featured, I'd recommend that ahead of VSCode for Java. Seconded! IDEA before VSCode before Eclipse before ... Sublime text, I guess? You don't need to pay for IDEA unless you need to use it for JS projects or need the paid support options.
|
# ? Apr 16, 2020 18:49 |
|
I absolutely would not be writing Java or Kotlin without IDEA. I feel a little weird about having a language so reliant on the IDE (especially with Kotlin, since unsurprisingly there isn't much alternative tooling out there), but it is a tool that makes everything about the language make more sense to me. On the other hand, I don't think you need to crack a book open and learn your whole IDE front to back before continuing. I'd run through a hello world in your IDE so you learn some of the basics, and then just learn incrementally. You should be trying to build and run apps and tests through your IDE (which is easy with IDEA's Maven/Gradle integration) and be comfortable with the debugger (which, if you've used a browser debugger before, you would be familiar with). The refactor tools are helpful but situational; you'll probably discover them when you need them. In addition, as a full-stack developer, I would not go overboard trying to use IDEA for everything, since (a) that actually is where you get into the part of IDEA that costs money and (b) trying to integrate things like your frontend builds into IDEA will require a lot more overhead than you'd probably want. I just keep VS Code and IntelliJ running simultaneously (and did grab the uber-basic VSCode Kotlin plugin just so I could take a peek at backend code without opening IntellIJ when I'm focusing on frontend).
|
# ? Apr 16, 2020 19:52 |
|
The help menu actually has some great stuff for learning IntelliJ
that and the "type what you want" shortcuts are great ways to explore as you go. You don't need to learn it all but there's a lot there that'll help you!
|
# ? Apr 17, 2020 01:52 |
|
IntelliJ is by far the best of the Java IDEs out there. Although in particular I disagree with the decision to remap ctrl-Y from undo, I think that causes a lot of needless suffering. No need to buy the full thing, the community edition is 95% of what you need (the big one being any sort of front-end editing). Netbeans is passable especially if you are using older Ant style stuff and you dont know what youre missing. Eclipse is eclipse, its an IDE designed by engineers, its incredibly extensible and anything is possible, and nothing is easy. The Turing Tarpit for IDEs. Frankly the best thing Ive found for editing frontends is... Notepad++. It does a pretty reasonable job of handling JSP syntax and there is no editor on the planet that can handle the nightmare of context-aware JSP editing. The include syntax and overlapping layers of JSP and JSTL means you basically have all the parseability of PHP calling CGI includes. Thymeleaf templating is strongly recommended for any sort of sanity. Paul MaudDib fucked around with this message at 02:47 on Apr 17, 2020 |
# ? Apr 17, 2020 02:43 |
|
Paul MaudDib posted:Thymeleaf templating is strongly recommended for any sort of sanity. I'm a big fan of Pebble (which is a port of Twig, Symfony's templating engine). Recommend it as an alternative for those that don't gel with the "everything is a tag attribute" approach of Thymeleaf and some others.
|
# ? Apr 17, 2020 03:57 |
|
Paul MaudDib posted:Thymeleaf templating is strongly recommended for any sort of sanity. Hell yes to this. Opening up my templates in a normal browser without having to start the server is great.
|
# ? Apr 17, 2020 05:08 |
|
Hello this is the Java thread!
|
# ? Apr 17, 2020 05:27 |
|
Splinter posted:I'm a big fan of Pebble (which is a port of Twig, Symfony's templating engine). Recommend it as an alternative for those that don't gel with the "everything is a tag attribute" approach of Thymeleaf and some others. A hearty recommendation of Pebble from my side also. We use it at work and i'm very happy with it. It seems to give you enough power to do things, but without ending in JSP territory where suddenly you find that your entire application code is now inside the JSP templates. Also I like the Twig/Pebble template inheritance/block override concept as I feel it really gives a lot of flexibility for not a huge amount of effort.
|
# ? Apr 17, 2020 08:25 |
|
I've used FreeMarker for some personal projects. It was pretty good at handling what I wanted.
|
# ? Apr 18, 2020 13:47 |
|
Pebble works pretty well for me too.
|
# ? Apr 18, 2020 16:38 |
Oh man I've been trying to set up IntelliJ and JDKs up so I can start playing around with Scala and boy do I remember why I left the Java ecosystem. Everything is somehow even more archaic than even C++. Does anyone know why, when I try to attach debugging in IntelliJ to the SBT console, it says everything is connected, but ir doesn't seem to stop at my breakpoints? I set it all up with JDK 8 since that is the only version I could get to play nice with SBT in IntelliJ.
|
|
# ? Apr 19, 2020 21:41 |
|
Joda posted:Oh man I've been trying to set up IntelliJ and JDKs up so I can start playing around with Scala and boy do I remember why I left the Java ecosystem. Everything is somehow even more archaic than even C++. I've never had any problems debugging Java code, so maybe Scala's the problem here?
|
# ? Apr 20, 2020 01:34 |
hooah posted:I've never had any problems debugging Java code, so maybe Scala's the problem here? Oh yeah, it's definitely a problem with how IntelliJ works with either Scala or SBT. We don't have a Scala thread though, so I'm asking here.
|
|
# ? Apr 20, 2020 02:38 |
So I have a Spring app where there are different roles that can have different permissions based on what they're supposed to be handling. Using repositories, is there any way to search for a certain matching Key/Value pair directly? Currently I'm just querying all of the roles and looping through each of their permissions. The map for a role that could manage events would look like this (It's written in Kotlin, but it's more of a general Spring question so hopefully it still fits here): code:
i vomit kittens fucked around with this message at 06:38 on Apr 25, 2020 |
|
# ? Apr 25, 2020 06:34 |
|
Can't you just put in only the permissions that are true and assume everything else is false? That way you only have to search for a key.
|
# ? Apr 25, 2020 06:38 |
|
I've got some fairly basic Thread-related questions while coming back to Java from a long time away. The last time I wrote Java professionally, it was an applet talking CORBA to the backend, I was using Eclipse, and checked code into CVS. I feel like I've got a working understanding of common concurrency issues and safety from spending time in Go recently, but Java's heavier thread abstraction leaves me with some questions. Specifically, my team inherited an Android app. It is using Go mobile bindings for some of its functionality, which we're working to port over to Kotlin or Java. I need to get up to speed on good JVM networking practices in general though because we also will be developing the Scala backend going forward. It's doing a lot of not-HTTP network calls, which means things that would normally be handled by a library have been hand-rolled.
Finally, is this a sane way to handle doing blocking tasks in response to UDP packets? I know it needs error handling. Let's say that doPacketProcessing is either CPU heavy, does blocking I/O, or both. code:
|
# ? Apr 27, 2020 06:36 |
|
Async i/o is better than having a bajillion threads, but it's overall not a huge deal. Having threads sit blocked on i/o doesn't really consume a lot of resources. With regards to callbacks, most well-behaved libraries (e.g. anything using ListenableFuture) expect you to pass in an ExecutorService or Handler or similar to actually run your callback on. If you intend to do heavy computation in your callback, you should make sure to pass in the ExecutorService for your background threadpool or a similar place where it's appropriate to do that computation.
|
# ? Apr 27, 2020 06:49 |
|
Kotlin coroutines are good, if you can use those.
|
# ? Apr 27, 2020 15:52 |
|
CPColin posted:Kotlin coroutines are good, if you can use those. They're just a quick trivial complete rewrite of your entire source away!
|
# ? Apr 27, 2020 16:02 |
|
carry on then posted:They're just a quick trivial complete rewrite of your entire source away! 1) Wrong 2) They're porting stuff over from a different language anyway
|
# ? Apr 27, 2020 18:29 |
|
Having an issue with some Buttons (org.eclipse.swt.widgets.Button), if I set their text to a string longer than about 5 characters, the text isn't displayed. The buttons themselves are pretty wide with ample room for the text, and in a Group using a FillLayout. Does anyone have any idea what the issue might be?
|
# ? Apr 28, 2020 12:18 |
|
chippy posted:Having an issue with some Buttons (org.eclipse.swt.widgets.Button), if I set their text to a string longer than about 5 characters, the text isn't displayed. The buttons themselves are pretty wide with ample room for the text, and in a Group using a FillLayout. Does anyone have any idea what the issue might be? Fuuuuuck I hate SWT so much
|
# ? Apr 28, 2020 15:34 |
|
chippy posted:Fuuuuuck I hate SWT so much Give me a little bit to dig through some old stuff I did and let me see if I have anything using SWT. Off hand, I know I have. JavaFX app using GridPane but that isn't exactly what you need. Is there a specific reason it HAS to be SWT or can you use something else for the GUI?
|
# ? Apr 28, 2020 16:03 |
|
Hekk posted:Give me a little bit to dig through some old stuff I did and let me see if I have anything using SWT. Off hand, I know I have. JavaFX app using GridPane but that isn't exactly what you need. Is there a specific reason it HAS to be SWT or can you use something else for the GUI? I'm an extending an existing GUI which has already been written in SWT and it's just what we use here so I don't think I've much of a choice. I guess I might be able to re-create it from scratch but I only needed to add a couple of buttons. I've ripped out almost all the other GUI components so I can try to add them in one-by-one and find out what's causing this, and I've discovered that the buttons are apparently determining their height from the length of their text I presume there's a layout manager causing this somewhere but I thought I'd commented them all out. Seems like such bizarre behaviour.
|
# ? Apr 28, 2020 16:32 |
|
Did someone swap the arguments for height and width somewhere in your code base? That's awful weird indeed.
|
# ? Apr 28, 2020 18:34 |
|
Hippie Hedgehog posted:Did someone swap the arguments for height and width somewhere in your code base? That's awful weird indeed. It's so messed up. They are just SWT Buttons. Current the parent composite has a vertical FillLayout, and then I'm adding a Group to that with a horizontal RowLayout, and then I'm adding the buttons to that. But I've tried so many different combinations at this point and they always seem to take their height from the text. I had zero loving clue what's going on at this point.
|
# ? Apr 29, 2020 12:29 |
|
Ignore dumb question, I was making things too complicated.
DreamingofRoses fucked around with this message at 23:00 on Apr 30, 2020 |
# ? Apr 30, 2020 21:21 |
|
chippy posted:It's so messed up. They are just SWT Buttons. Current the parent composite has a vertical FillLayout, and then I'm adding a Group to that with a horizontal RowLayout, and then I'm adding the buttons to that. But I've tried so many different combinations at this point and they always seem to take their height from the text. I had zero loving clue what's going on at this point. I ended up basically rebuilding the layout from scratch and the weird behaviour went away. It was easier than figuring out what the previous guy had done.
|
# ? May 4, 2020 10:14 |
|
chippy posted:I ended up basically rebuilding the layout from scratch and the weird behaviour went away. It was easier than figuring out what the previous guy had done. This has absolutely been my experience with SWT as well.
|
# ? May 4, 2020 13:37 |
|
Sorry for a newbie question, but I've become deeply lost on a homework problem regarding implementing a generic tree structure that is supposed to imitate a string-keyed dictionary structure by having each node of the tree have 26 children corresponding to letters of the alphabet, which then allow you to access the value of a node by traversing down the tree one letter at a time. What I'm having trouble with is initializing the array of links to children, which are explicitly stated to be initialized by the constructor and to be null until accessed, but I can't initialize a generic array of 26 nulls. I'm probably fundamentally misunderstanding something, but here's my latest stab at the code:code:
|
# ? May 5, 2020 02:06 |
|
Xenophanes posted:Sorry for a newbie question, but I've become deeply lost on a homework problem regarding implementing a generic tree structure that is supposed to imitate a string-keyed dictionary structure by having each node of the tree have 26 children corresponding to letters of the alphabet, which then allow you to access the value of a node by traversing down the tree one letter at a time. What I'm having trouble with is initializing the array of links to children, which are explicitly stated to be initialized by the constructor and to be null until accessed, but I can't initialize a generic array of 26 nulls. I'm probably fundamentally misunderstanding something, but here's my latest stab at the code: Are you required to use an array? Are you required to use generics? I'm asking because even in my quick searches, it comes out pretty strongly that arrays of generics are just flat out not allowed in Java: https://www.ibm.com/developerworks/java/library/j-jtp01255/index.html It seems like one of those two requirements was to give to make this work. To get the exact behavior you seem to be looking for, I'd use an ArrayList, but of course, I don't know the constraints of your assignment, this might not be allowed: code:
carry on then fucked around with this message at 04:28 on May 5, 2020 |
# ? May 5, 2020 03:54 |
|
Yeah, those were both requirements. After poking at it for about 6 hours I got it to work(?) with code:
Xenophanes fucked around with this message at 05:20 on May 5, 2020 |
# ? May 5, 2020 05:17 |
|
|
# ? Apr 26, 2024 02:24 |
|
Xenophanes posted:Yeah, those were both requirements. After poking at it for about 6 hours I got it to work(?) with I think the difference here that you were creating it as Object[] originally, but here as MyNode[], not that it's on the same line.
|
# ? May 5, 2020 06:14 |