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

Handle System.exit() calls #17

Closed
thepieterdc opened this issue Oct 5, 2019 · 3 comments · Fixed by #21
Closed

Handle System.exit() calls #17

thepieterdc opened this issue Oct 5, 2019 · 3 comments · Fixed by #21
Labels
bug Something isn't working

Comments

@thepieterdc
Copy link
Member

Whenever a student calls System.exit(), the judge exits immediately, causing the partial json output to be invalid, resulting in an Internal Error on Dodona. These calls can be intercepted by using a custom SecurityManager, similar to the way the ExpectedSystemExit rule works.

Proof of concept of this issue:

Exercise.java

public class Exercise {
    public boolean something() {
        System.exit(0);
        return false;
    }
}

ExerciseTest.java

public class ExerciseTest {
    @Test
    public void testSomething() {
        Assert.assertTrue(new Exercise().something());
    }
}

Output:

{
  "description": {
    "format": "code",
    "description": "testSomething(ExerciseTest)"
  },
  "command": "start-context"
@thepieterdc thepieterdc added the bug Something isn't working label Oct 5, 2019
@ninewise
Copy link

ninewise commented Oct 5, 2019

See #18

@thepieterdc
Copy link
Member Author

See also #7

@ninewise
Copy link

ninewise commented Oct 5, 2019

Perhaps that earlier idea was better than my current; seems less likely to break on random stuff in complicated tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants