Skip to content

Conversation

@koppor
Copy link
Member

@koppor koppor commented Sep 14, 2025

Makes JabSrv more modular

Steps to test

  1. Start JabRef
  2. Open a library
  3. Open https://jabref.github.io/jabmap/
  4. Interact with JabMap - works :)

Mandatory checks

@Override
public Void call() throws InterruptedException {
// The server serves the last opened files (see org.jabref.http.server.LibraryResource.getLibraryPath)
// The server serves the last opened files (see org.jabref.http.server.resources.LibraryResource.getLibraryPath)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment does not add new information or reasoning to the code. It merely restates what the code is doing, which is discouraged.

@koppor koppor added dev: code-quality Issues related to code or architecture decisions project: jabcon component: jabsrv JabRef's http server labels Sep 14, 2025
@trag-bot
Copy link

trag-bot bot commented Sep 14, 2025

@trag-bot didn't find any issues in the code! ✅✨

@Siedlerchr Siedlerchr added this pull request to the merge queue Sep 14, 2025
try {
libraryAsString = Files.readString(library);
} catch (IOException e) {
LOGGER.error("Could not read library {}", library, e);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The try block covers too many statements. It should only cover the statement that might throw the exception, improving readability and maintainability.

* @return a stream to the Chocolate.bib file in the classpath (is null only if the file was moved or there are issues with the classpath)
*/
private @Nullable InputStream getChocolateBibAsStream() {
return BibDatabase.class.getResourceAsStream("/Chocolate.bib");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning null from a method is discouraged. Consider using Optional to avoid potential NullPointerExceptions.

*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getJabMapJson(@PathParam("id") String id) throws IOException {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method returns a JSON string directly, which could be null if the file reading fails. It should return an Optional to avoid returning null.

}

private java.nio.file.Path getJabMapDemoPath() {
java.nio.file.Path result = java.nio.file.Path.of(System.getProperty("java.io.tmpdir")).resolve("demo.jmp");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of System.getProperty("java.io.tmpdir") is correct, but the path should be managed using modern Java best practices like Path.of() instead of Paths.get().

auto-merge was automatically disabled September 14, 2025 20:00

Pull Request is not mergeable

Merged via the queue into JabRef:main with commit 968d289 Sep 14, 2025
42 of 43 checks passed
@Siedlerchr Siedlerchr deleted the fix-jabsrv branch September 14, 2025 20:10
Siedlerchr added a commit that referenced this pull request Sep 17, 2025
* upstream/main:
  Add new check for format (#13909)
  Consistent casing in fieldnames (#13867)
  Revert "Pressing TAB in last field in entry editor moves focus to the next ta…" (#13912)
  Fix YAML
  Fix on-pr-opened-updated.yml syntax
  Pressing TAB in last field in entry editor moves focus to the next tab's first field  (#13870)
  Modularize JabSrv (#13908)
  New translations jabref_en.properties (Italian) (#13907)
  Remove wrong `assert` statement (#13906)
  Add .git-blame-ignore-revs (#13884)
  Do not show transprot info messages (#13904)
  Pubmed api key support (#13899)
  Fix warnings for native access
  Fix automerge workflow (#13903)
  Add comment on issue on binary (#13902)
  Have checkstyle and VCS configuration distributed (#13900)
  Add unknown field to lsp consistency check (#13880)
  Put config for general tab if missing (#13901)
  Fix autosave manager exception on shutdown (#13882)
@koppor koppor mentioned this pull request Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: jabsrv JabRef's http server dev: code-quality Issues related to code or architecture decisions project: jabcon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants