Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ plugins:
sonar-java:
enabled: true
config:
sonar.java.source: 8
sonar.java.source: 21
2 changes: 1 addition & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ name = "java"
enabled = true

[analyzers.meta]
runtime_version = "16"
runtime_version = "21"
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: 'adopt'
java-version: '17'
java-version: '21'
cache: 'maven'

# Initializes the CodeQL tools for scanning.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
- name: Cache SonarQube packages
uses: actions/cache@v5
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
- name: Generate the javadoc
run: mvn --batch-mode -ntp install -DskipTests && mvn --batch-mode -ntp javadoc:javadoc
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/setup-java@v5
with:
distribution: 'adopt'
java-version: '17'
java-version: '21'
cache: 'maven'
server-id: central
server-username: MAVEN_CENTRAL_USERNAME
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar-pr-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v5
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
- name: Cache SonarQube packages
uses: actions/cache@v5
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ manually.

| Concern | Technology |
|---|---|
| Language | Java 17 |
| Language | Java 21 |
| Build | Apache Maven (multi-module) |
| Unit tests | JUnit 5 (`junit-jupiter` 5.11.4) |
| Assertions | Hamcrest 3.0 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
* {@link #getString(Locale, String, Object...)} require an explicit
* {@code Locale} parameter and never touch thread-local state.
* These are the preferred path for new code.</li>
* <li><b>Stateful (legacy)</b> — {@link #getString(String)} and
* <li><b>Stateful</b> — {@link #getString(String)} and
* {@link #getString(String, Object...)} read from a per-thread
* {@link ResourceBundle} controlled by {@link #setLocale(Locale)}.
* Scheduled for removal in a future major release.</li>
* {@link ResourceBundle} using the JVM default locale.</li>
* </ul>
*
* All lookups degrade gracefully: if a key is missing in the requested bundle
Expand Down Expand Up @@ -47,29 +46,17 @@ public static Messages getInstance() {
}

/**
* Sets the locale of the bundle for the current thread.
* Clears the thread-local {@link ResourceBundle} for the current thread.
*
* @param locale the locale to set.
* @deprecated Use {@link #getString(Locale, String)} instead.
* Scheduled for removal in a future major release.
*/
@Deprecated(since = "2.17.0", forRemoval = true)
public void setLocale(final Locale locale) {
bundleHolder.set(ResourceBundle.getBundle(BUNDLE_NAME, locale));
}

/**
* Clears the locale for the current thread, resetting it to the JVM default.
*
* <p>Must be called in thread-pool environments (e.g., servlets, Spring)
* after each request to prevent locale leakage between tasks on the same thread.
* <p>Call this when a thread finishes using the stateful API
* ({@link #getString(String)} / {@link #getString(String, Object...)}),
* especially in thread pools, to prevent {@link ThreadLocal} memory leaks.
*
* @deprecated Use {@link #getString(Locale, String)} instead.
* Scheduled for removal in a future major release.
* <p>Not needed for the stateless overloads {@link #getString(Locale, String)}
* and {@link #getString(Locale, String, Object...)}.
*/
@Deprecated(since = "2.17.0", forRemoval = true)
public void clearLocale() {
bundleHolder.remove();
public static void cleanup() {
INSTANCE.bundleHolder.remove();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,12 @@
import java.util.Properties;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

class MessagesTest {

@Test
@SuppressWarnings("java:S5738")
void testSetLocale() {
Messages.getInstance().setLocale(Locale.FRENCH); // NOSONAR java:S5738
assertEquals("peu", Messages.getInstance().getString("CloudQuantity.FEW"));
Messages.getInstance().setLocale(Locale.ENGLISH); // NOSONAR java:S5738
assertEquals("few", Messages.getInstance().getString("CloudQuantity.FEW"));
Messages.getInstance().clearLocale(); // NOSONAR java:S5738
}

@Test
@SuppressWarnings("java:S5738")
void testClearLocale() {
Messages.getInstance().setLocale(Locale.FRENCH); // NOSONAR java:S5738
assertEquals("peu", Messages.getInstance().getString("CloudQuantity.FEW"));
Messages.getInstance().clearLocale(); // NOSONAR java:S5738
assertDoesNotThrow(() -> Messages.getInstance().getString("CloudQuantity.FEW"));
}

@Test
void testGetStringWithArgs() {
assertEquals("ceiling varying between 5 and 15 feet",
Expand Down Expand Up @@ -73,6 +53,14 @@ void testMissingKeyWithArgsReturnsKey() {
assertEquals("NonExistent.Key", Messages.getInstance().getString(Locale.FRENCH, "NonExistent.Key", "arg1"));
}

@Test
void testCleanup() {
Messages messages = Messages.getInstance();
String before = messages.getString("CloudQuantity.FEW");
Messages.cleanup();
assertEquals(before, messages.getString("CloudQuantity.FEW"));
}

@ParameterizedTest
@ValueSource(strings = {"messages_de", "messages_es", "messages_fr", "messages_it",
"messages_pl_PL", "messages_ru_RU", "messages_tr_TR", "messages_zh_CN"})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.junit.jupiter.api.Assertions.*;

import io.github.mivek.internationalization.Messages;
import java.util.Locale;
import org.junit.jupiter.api.Test;

Expand All @@ -22,7 +21,6 @@ void testGetEnumValid() {

@Test
void testToString() {
Messages.getInstance().setLocale(Locale.ENGLISH);
assertEquals("Severe Mixed Icing", IcingIntensity.SEVERE_MIXED_ICING.toString());
assertEquals("Severe Mixed Icing", IcingIntensity.SEVERE_MIXED_ICING.toString(Locale.ENGLISH));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static org.junit.jupiter.api.Assertions.*;

import io.github.mivek.internationalization.Messages;
import java.util.Locale;
import org.junit.jupiter.api.Test;

Expand All @@ -23,7 +22,6 @@ void testGetEnumValid() {

@Test
void testToString() {
Messages.getInstance().setLocale(Locale.ENGLISH);
assertEquals("Extreme turbulence", TurbulenceIntensity.EXTREME.toString());
assertEquals("Extreme turbulence", TurbulenceIntensity.EXTREME.toString(Locale.ENGLISH));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ public AbstractTafTrend<BeginningValidity> parse(final String[] code) {
return trend;
}

/**
* @return The singleton instance.
* @deprecated Use the constructor instead.
*/
@Deprecated(forRemoval = true, since = "2.19.0")
public static FMTrendParser getInstance() {
return new FMTrendParser();
}

/**
* Parses the validity of a {@link FMTafTrend} object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,6 @@ public MetarParser(final CommonCommandSupplier commonCommandSupplier, final Rema
supplier = Objects.requireNonNull(metarCommandSupplier);
}

/**
* Get instance method.
*
* @return the instance of MetarParser.
* @deprecated Use the constructor instead.
*/
@Deprecated(forRemoval = true, since = "2.19.0")
public static MetarParser getInstance() {
return new MetarParser();
}

/**
* This is the main method of the parser. This method checks if the airport
* exists. If it does then the metar code is decoded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ public TafProbTrend parse(final String[] code) {
return trend;
}

/**
* @return The ProbTrendParser instance.
* @deprecated Use the constructor instead.
*/
@Deprecated(forRemoval = true, since = "2.19.0")
public static ProbTrendParser getInstance() {
return new ProbTrendParser();
}

/**
* parses the probability out of PROB.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,4 @@ public String parse(final String remark) {
return sb.toString();
}

/**
* @deprecated Use the default constructor instead.
* @return the instance of the parser.
*/
@Deprecated(forRemoval = true, since = "2.19.0")
public static RemarkParser getInstance() {
return new RemarkParser();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ public TAFParser(final CommonCommandSupplier commonCommandSupplier, final Remark
supplier = tafCommandSupplier;
}

/**
* @deprecated Use constructor instead.
* @return the instance.
*/
@Deprecated(forRemoval = true, since = "2.19.0")
public static TAFParser getInstance() {
return new TAFParser();
}

@Override
public TAF parse(final String code) throws ParseException {
String[][] lines = extractLineTokens(code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ public TrendValididyParser() {
this(new CommonCommandSupplier(), new RemarkParser(), new TAFCommandSupplier());
}

/**
* @deprecated Use constructor instead.
* @return The TrendValidityParser instance.
*/
@Deprecated(forRemoval = true, since = "2.19.0")
public static TrendValididyParser getInstance() {
return new TrendValididyParser();
}

@Override
public TafTrend parse(final String[] code) {
TafTrend trend = FactoryProvider.getTAFTrendFactory().create(code[0]).orElseThrow(() -> new IllegalArgumentException(code[0]));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
package io.github.mivek.command.remark;

import io.github.mivek.internationalization.Messages;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Locale;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

class HourlyMaximumMinimumTemperatureCommandTest {

@BeforeEach
void setup() {
Messages.getInstance().setLocale(Locale.ENGLISH);
}

@Test
void testExecute() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
package io.github.mivek.command.remark;

import io.github.mivek.internationalization.Messages;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Locale;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

class HourlyMaximumTemperatureCommandTest {

@BeforeEach
void setup() {
Messages.getInstance().setLocale(Locale.ENGLISH);
}

@Test
void testExecuteBelowZero() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
package io.github.mivek.command.remark;

import io.github.mivek.internationalization.Messages;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Locale;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

class HourlyMinimumTemperatureCommandTest {

@BeforeEach
void setup() {
Messages.getInstance().setLocale(Locale.ENGLISH);
}

@Test
void testExecuteWithNegativeTemperature() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
package io.github.mivek.command.remark;

import io.github.mivek.internationalization.Messages;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Locale;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

class HourlyPrecipitationAmountCommandTest {

@BeforeEach
void setup() {
Messages.getInstance().setLocale(Locale.ENGLISH);
}

@Test
void testExecute() {
Expand Down
Loading
Loading