-
Notifications
You must be signed in to change notification settings - Fork 47
ModuleLayerHandler.getLayer throws NPE if layer is missing #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I understand your case here, but when would this happen? |
@Johni0702 What are you doing to trigger this crash? |
Literally what I said:
|
But why, as I stated in the PR for this, we construct the layer as soon as we can, so what are you doing that you would want to access the game layer before it is even build? Don't get me wrong I think we should fix this, but that does not mean I don't need more context. |
It's complicated. I've got a modloader-independent code base that interacts with various modloader-specific sub-projects at various points in time during the mod loading process. |
I understand that you are invoking it in such a context, just not why specifically? |
As I said, it's complicated, and I do not wish to waste more time explaining it. |
I don't understand how this is wasting time. If you want me to merge the fix in a way that I can be confident that it won't cause issues else where, and in a way that guarantees me that there are no issues like this else where, I need to know the context of the call. I don't ask for your help with the research just a pointer to the code that is causing the issue, so that I can verify the problem and consider your use case in future PR merges or redesigns. If you feel like you don't want to spend time helping me get a better understanding of the issue and its context, I don't need to spend the time reviewing, testing and verifying the pr which is ready to be merged and I am pretty sure nobody else will spend time on that either then. |
Why did you close this ticket? |
Because this is a trivial issue with a dead simple fix and you're wasting an unreasonable amount of time on it. |
I totally understand your position, and it is indeed a trivial fix. But even trivial fixes can have far reaching consequences. For example there are two primary ways we can deal with this issue:
Do you know understand why having the context is a necessary evil that I need to make a proper decision on this issue? |
Ok, I think I see were our difference in perception comes from: I have not explicitly stated this, but I am not at all suggesting that the (implied) API should be in any way changed. The way this method is currently defined (with an To me this looks like a straight forward bug in the implementation which simply doesn't match the implied API. If a layer is missing, I'm expecting it to return Note how for none of this it actually matters why getLayer is called. I wasn't questioning the API design itself (where the actual use case does matter), just the apparent disconnect between heavily implied behavior (both in API and in attempted implementation) and actual behavior (throwing a NPE, which is totally unexpected).
There is a good reason in my case (I attempted to explain that in short in one of my replies above). In any case, the current API already deals with it, that's part of the motivation for why |
I understand your position just fine and there was no difference in perception. Just a difference in how we deal with issues like this. Now currently that optional is likely there for a reason so I think the fix is appropriate, but I would just like to know how you use this API practically, maybe there is something we can do to get you a better API besides just fixing the bug, and helping you make your code better understandable by making the API better. However if you don't want to show me your code, then say so, and I will see what I can do in the mean time. |
As I've said, the API is perfectly fine for my use case. If I wanted a better API for what I'm doing, I would have opened an issue asking for one. |
Fine I will triage it again on this release then. |
modlauncher/src/main/java/cpw/mods/modlauncher/ModuleLayerHandler.java
Lines 86 to 88 in 9b69c82
Calling this method with a Layer that's not yet available throws a NullPointerException instead of returning an empty Optional as one might expect from its signature.
The text was updated successfully, but these errors were encountered: