Skip to content
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

java.lang.ArrayIndexOutOfBoundsException: -1 #131

Closed
pihvi opened this issue Nov 28, 2017 · 2 comments
Closed

java.lang.ArrayIndexOutOfBoundsException: -1 #131

pihvi opened this issue Nov 28, 2017 · 2 comments

Comments

@pihvi
Copy link

pihvi commented Nov 28, 2017

I had a TMC exercise open in Idea when I opened another non TMC project in new window, where I got this error:

-1
java.lang.ArrayIndexOutOfBoundsException: -1
at fi.helsinki.cs.tmc.intellij.services.ObjectFinder.findCurrentProject(ObjectFinder.java:174)
at fi.helsinki.cs.tmc.intellij.io.ProjectOpener.openProject(ProjectOpener.java:36)
at fi.helsinki.cs.tmc.intellij.io.ProjectOpener.openProject(ProjectOpener.java:76)
at fi.helsinki.cs.tmc.intellij.services.exercises.NextExerciseFetcher.openFirst(NextExerciseFetcher.java:90)
at fi.helsinki.cs.tmc.intellij.services.exercises.ExerciseDownloadingService$2.lambda$run$0(ExerciseDownloadingService.java:133)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:314)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.a(LaterInvocator.java:416)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:399)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:821)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:649)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

@pirtnea
Copy link
Contributor

pirtnea commented Dec 8, 2017

I tried to replicate this on my computer and I'm not getting any errors after opening or running the non-TMC project. Did this appear right after opening the non-TMC project window or did you do something else to trigger the problem?

@pihvi
Copy link
Author

pihvi commented Dec 8, 2017

I don't think I did anything else. But looking at where the error comes from, maybe you can think of a case where returned projects array is empty, then this error will happen here:

https://github.com/testmycode/tmc-intellij/blob/master/tmc-plugin-intellij/src/main/java/fi/helsinki/cs/tmc/intellij/services/ObjectFinder.java#L174

That is, there is a possibility for that index out of bounds case, when the returned project array is an empty array and maybe it should be checked in any case.. I don't know why was that code executed when I opened another non TMC project while one TMC project was open or why did it return an empty array in that case. But an easy fix for now would be to check if the array is non empty before trying to return its last value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants