javabotjreicher's title: "eclipse.jdt.ls/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java at main · eclipse-jdtls/eclipse.jdt.ls · GitHub"
NeXeNhrmm, i've been using this idiom to manage scope for a library i'm building. i put it in a try with resources statement and i was doing a simple try (Scope s = Scopes.get(ScopeType.WHATEVER)) { } to get scoped blocks that auto close (implementing auto closable)
NeXeNwell turns out my IDE i guess shows a warning, since the local variable s isn't used anywhere.....you know it's defined in the try statement and never used because i don't need to, it just initiates a scope and is auto closable to make it clean so there's no leakage or residual scope bugs.
NeXeNso i'm curious, if i replace it with var _ = Scopes.get() will the _ be ignored by the ide's "problems". i'm using a vsclone and you know that standard java plugin from redhat
NeXeNjreicher: i'm wondering what harm it would be to do that. i guess none since i don't often fail to use something i defined in local scope
deeboif your min version is a java version that supports _, it should be fine, we have that all over our code to specifically get around the unused variable stuff
NeXeNyeah i don't have local unused vars ever hardly, but this time i chose it as a pattern to ease the headache of edge cases. allowing it to autoclose makes it so much easier and more robust
deebofor that specific use case, it might even make more sens to do Scopes.get(...).inScope((_) -> ...);, or without the param if it's never needed
* pr070cal joined #java
deeboweird that "anonymous" try-with-resource is not supported though
deeboi sort of remember using it, but looking at the code, it's always with a resource, even if not referenced, like http calls etc
* Henryx joined #java
* Enissay joined #java
* Para joined #java
* Adrian35 joined #java
* acidjnk joined #java
* Adrian35 joined #java
* fed-kaczynski joined #java
* polyrob joined #java
jreicherFWIW I would also use _ in that situation, but I haven't had to do it in practice.
* A_Dragon joined #java
NeXeNyeah i thought about lambda, but i am specifically trying to avoid proxy objects
* fgarcia_ joined #java
* fgarcia__ joined #java
* MikeBux joined #java
* JazzJackalope9 joined #java
* ChaiTRex joined #java
* iusr joined #java
NeXeNyup, changing everything to var _ = solves the issue. just have to state it clearly in the docs. maybe someone will come up with a good fix like a config value but whatever, works for now
ParaIs it VS Code complaining or actual javac?
* Cae2 joined #java
* hwpplayer1 joined #java
* pebble joined #java
* MikeBux joined #java
* lord4163 joined #java
jreicherNeXeN: why do you not consider var _ a fix? Not only does it not generate a warning but it also states the intent of the code. It probably doesn't even need documentation.
jreicherJust in case it helps. You might already know about it.
* lord4163 joined #java
* hwpplayer1 joined #java
* Nemu64 joined #java
* ForeverDreaming joined #java
hassoon'morning
Opticgood morning
* taylan joined #java
Opticthis morning's battle: figure out why the scope claim in my jwt is missing when it gets to spring's JwtGrantedAuthoritiesConverter
Opticif you see a laptop flying from a building window, that's me
dreamrealnoted
* leppard joined #java
hassoonOptic: probably the jwt decoder's fault ?
* Soulcatcher joined #java
Opticyeah i'm working my way up the chain in the debugger
* scottg489 joined #java
* jamezp joined #java
Opticomg figured it it out, it's because I wasn't REQUESTING the scopes in intellij httpclient. :P 100% PEBKAC
hassoonintellij's httpclient ?
dreamrealhappens a lot and has happened to all of us, probably. To the ones it has NOT happened to: well, you just ain't tried yet or you're lying about it :D
Optichasson i'm using it for debugging... the actual application requests the scopes properly but my debug setup did not
* hwpplayer1 joined #java
hassooni see
Opticif you use the IDE i recommend checking out the feature, it's handy. saves jumping out to something like postman or bruno
hassooncool; +1
ParaIntelliJ's built-in http client is pretty nifty for API testing as well.
* bionade24 joined #java
* Solstice_21 joined #java
* Solstice_21 joined #java
* hwpplayer1 joined #java
* Solstice_21 joined #java
* metalmaniac joined #java
* hwpplayer1 joined #java
* Cae2 joined #java
* jontxu joined #java
* Adrian35 joined #java
* gas51627 joined #java
gas51627Hi all, should I try to make my services singletons, that is, existing for the duration of the running app or is it fine to create a service object each time I get a request?
gas51627In other words, what can be a singleton, should it be a singleton?
nimajesingleton means there can be only one object of that class and you should avoid that if possible, but your app holding onto one instance of some class and use that for all requests can be a good idea in some cases, that depends on your use case and other tradeoffs
dreamrealgas51627: it depends on what they do and what they need
dreamrealand how you're building them
dreamrealthere's no answer that fits in a general sense