playframework / playframework/play1

Under Linux, Play! does not sort allClasses list in ApplicationClassloader - wrong order of job execution

Open
#1,291 2 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.6k
Forks
671
Avg merge
12d 15h
Merged PRs (30d)
1

Description

If I want to do some work on application start using @OnApplicationStart annotation, it is not guaranteed that these jobs will be executed with priority. To overcome this, it is advised to prefix these classes with "A". After loading all classes on application start, Play! is sorting the list WHILE NOT in precompiled mode (line 449 in ApplicationClassloader class on Play! 1.5.2). While IN precompiled mode, Play! does not sort the list and job classes are executed in order they were put on the list. Under Windows typically this will be in alphabetical order, under Linux it is not guaranteed that the order will be alphabetical.

To fix this, Collections.sort:449 in class ApplicationClassloader should be executed after Play! is done with populating the allClasses list (after the else statement).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect ApplicationClassloader, especially line 449 and the code that populates allClasses in precompiled mode. Confirm the ordering behavior for @OnApplicationStart jobs under Linux and Windows; done means the populated list is sorted before job execution in both modes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.