From 5f5d1b68b7fb7906e2f91a2a98d50e3b7d308a98 Mon Sep 17 00:00:00 2001 From: Peter Major Date: Mon, 25 Nov 2024 21:29:16 +0000 Subject: [PATCH 1/3] Migrate new Locale constructor invocations to Locale.of calls --- .../wicket/threadtest/apps/app1/Home.java | 6 ++-- .../java/org/apache/wicket/LocalizerTest.java | 2 +- .../apache/wicket/PageMarkupLoadingTest.java | 6 ++-- .../AbstractResourceReferenceMapperTest.java | 4 +-- .../BasicResourceReferenceMapperTest.java | 6 ++-- .../PackageResourceReferenceTest.java | 8 ++--- .../resource/ResourceStreamLocatorTest.java | 30 +++++++++---------- .../CachingResourceStreamLocatorTest.java | 4 +-- .../locator/ResourceNameIteratorTest.java | 6 ++-- .../DefaultMarkupCacheKeyProviderTest.java | 16 +++++----- .../html/form/LocalizedErrorMessageTest.java | 10 +++---- .../html/form/ValidatorPropertiesTest.java | 2 +- .../markup/html/form/imagebutton/Home.java | 8 ++--- .../form/imagebutton/ImageButtonTest.java | 2 +- .../apache/wicket/markup/html/image/Home.java | 8 ++--- .../wicket/markup/html/image/ImageTest.java | 2 +- .../protocol/http/WicketFilterTest.java | 2 +- .../StringResourceLoaderTestBase.java | 4 +-- .../locator/LocaleResourceNameIterator.java | 4 +-- .../http/mock/MockHttpServletRequest.java | 4 +-- .../apache/wicket/resource/ResourceUtil.java | 6 ++-- .../forminput/FormInputApplication.java | 8 ++--- .../org/apache/wicket/examples/pub/Home.java | 12 ++++---- .../org/apache/wicket/examples/pub2/Home.java | 12 ++++---- .../examples/requestmapper/LocaleHelper.java | 4 +-- .../wicket/util/resource/ResourceUtils.java | 2 +- .../convert/converters/ConvertersTest.java | 2 +- 27 files changed, 90 insertions(+), 90 deletions(-) diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java index 2f2d1d34d6a..c097242034c 100644 --- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java +++ b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java @@ -324,9 +324,9 @@ public LocaleDropDownChoice(String id) } /** Relevant locales wrapped in a list. */ - private static final List LOCALES = Arrays.asList(Locale.ENGLISH, new Locale("nl"), - Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, new Locale("pt", "BR"), - new Locale("fa", "IR"), new Locale("da", "DK")); + private static final List LOCALES = Arrays.asList(Locale.ENGLISH, Locale.of("nl"), + Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, Locale.of("pt", "BR"), + Locale.of("fa", "IR"), Locale.of("da", "DK")); /** available sites for the multiple select. */ private static final List SITES = Arrays.asList("The Server Side", "Java Lobby", diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java index 40b92cbb975..fd461d8e383 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/LocalizerTest.java @@ -179,7 +179,7 @@ void testTwoComponents() assertEquals("value 1", localizer.getString("null", page.drop1)); assertEquals("value 2", localizer.getString("null", page.drop2)); - Session.get().setLocale(new Locale("nl")); + Session.get().setLocale(Locale.of("nl")); assertEquals("waarde 1", localizer.getString("null", page.drop1)); assertEquals("waarde 2", localizer.getString("null", page.drop2)); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java index 05486cd4355..b5ba6e38c59 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/PageMarkupLoadingTest.java @@ -49,7 +49,7 @@ void english() throws Exception @Test void dutch() throws Exception { - tester.getSession().setLocale(new Locale("nl")); + tester.getSession().setLocale(Locale.of("nl")); tester.startPage(Page1.class); tester.assertRenderedPage(Page1.class); tester.assertResultPage(getClass(), "PageMarkupLoadingTest$Page1_nl_expected.html"); @@ -63,7 +63,7 @@ void dutch() throws Exception @Test void testDutchMyStyle() throws Exception { - tester.getSession().setLocale(new Locale("nl")); + tester.getSession().setLocale(Locale.of("nl")); tester.getSession().setStyle("mystyle"); tester.startPage(Page1.class); tester.assertRenderedPage(Page1.class); @@ -78,7 +78,7 @@ void testDutchMyStyle() throws Exception @Test void dutchMyStyleMyVar() throws Exception { - tester.getSession().setLocale(new Locale("nl")); + tester.getSession().setLocale(Locale.of("nl")); tester.getSession().setStyle("mystyle"); tester.startPage(Page2.class); tester.assertRenderedPage(Page2.class); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java index ee667929b4c..13339496e37 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/AbstractResourceReferenceMapperTest.java @@ -133,7 +133,7 @@ public IResource getResource() }; ResourceReference reference2 = new ResourceReference( - AbstractResourceReferenceMapperTest.class, "reference2/name2", new Locale("en", "en"), + AbstractResourceReferenceMapperTest.class, "reference2/name2", Locale.of("en", "en"), null, null) { private static final long serialVersionUID = 1L; @@ -146,7 +146,7 @@ public IResource getResource() }; private ResourceReference reference2_a = new ResourceReference( - AbstractResourceReferenceMapperTest.class, "reference2/name2", new Locale("en", "en"), + AbstractResourceReferenceMapperTest.class, "reference2/name2", Locale.of("en", "en"), "style", null) { private static final long serialVersionUID = 1L; diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java index 550424ecfcc..6acd50cfefc 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/mapper/BasicResourceReferenceMapperTest.java @@ -162,7 +162,7 @@ void decode3() assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class); ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler; assertEquals(resource2, h.getResource()); - assertEquals(new Locale("en", "en"), h.getLocale()); + assertEquals(Locale.of("en", "en"), h.getLocale()); assertNull(h.getStyle()); assertNull(h.getVariation()); assertEquals(0, h.getPageParameters().getIndexedCount()); @@ -180,7 +180,7 @@ void decode3A() assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class); ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler; assertEquals(resource2, h.getResource()); - assertEquals(new Locale("en", "en"), h.getLocale()); + assertEquals(Locale.of("en", "en"), h.getLocale()); assertEquals("style", h.getStyle()); assertNull(h.getVariation()); assertEquals(0, h.getPageParameters().getIndexedCount()); @@ -210,7 +210,7 @@ void decode4() assertThat(handler).isInstanceOf(ResourceReferenceRequestHandler.class); ResourceReferenceRequestHandler h = (ResourceReferenceRequestHandler)handler; assertEquals(resource2, h.getResource()); - assertEquals(new Locale("en", "en"), h.getLocale()); + assertEquals(Locale.of("en", "en"), h.getLocale()); assertNull(h.getStyle()); assertNull(h.getVariation()); assertEquals("v1", h.getPageParameters().get("p1").toString()); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java index 8b7e05aac38..3e230660255 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/request/resource/PackageResourceReferenceTest.java @@ -70,7 +70,7 @@ class PackageResourceReferenceTest extends WicketTestCase { private static Class scope = PackageResourceReferenceTest.class; private static final Locale defaultLocale = Locale.CHINA; - private static final Locale[] locales = { null, new Locale("en"), new Locale("en", "US") }; + private static final Locale[] locales = { null, Locale.of("en"), Locale.of("en", "US") }; private static final String[] styles = { null, "style" }; private static final String[] variations = { null, "var" }; @@ -173,7 +173,7 @@ void resourceResponse() @Test void sessionAttributesRelevance() { - for (Locale locale : new Locale[] { new Locale("en"), new Locale("en", "US") }) + for (Locale locale : new Locale[] { Locale.of("en"), Locale.of("en", "US") }) { tester.getSession().setLocale(locale); for (String style : styles) @@ -198,10 +198,10 @@ void sessionAttributesRelevance() @Test void userAttributesPreference() { - tester.getSession().setLocale(new Locale("en")); + tester.getSession().setLocale(Locale.of("en")); tester.getSession().setStyle("style"); - Locale[] userLocales = { null, new Locale("pt"), new Locale("pt", "BR") }; + Locale[] userLocales = { null, Locale.of("pt"), Locale.of("pt", "BR") }; String userStyle = "style2"; for (Locale userLocale : userLocales) diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java index cb9a7242f6c..89be4a22764 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/ResourceStreamLocatorTest.java @@ -44,21 +44,21 @@ */ public class ResourceStreamLocatorTest extends WicketTestCase { - private final Locale locale_de = new Locale("de"); - private final Locale locale_de_DE = new Locale("de", "DE"); - private final Locale locale_de_DE_POSIX = new Locale("de", "DE", "POSIX"); - private final Locale locale_de_POSIX = new Locale("de", "", "POSIX"); - private final Locale locale_de_CH = new Locale("de", "CH"); - - private final Locale locale_en = new Locale("en"); - private final Locale locale_en_US = new Locale("en", "US"); - private final Locale locale_en_US_WIN = new Locale("en", "US", "WIN"); - private final Locale locale_en_WIN = new Locale("en", "", "WIN"); - - private final Locale locale_fr = new Locale("fr"); - private final Locale locale_fr_FR = new Locale("fr", "FR"); - private final Locale locale_fr_FR_WIN = new Locale("fr", "FR", "WIN"); - private final Locale locale_fr_WIN = new Locale("fr", "", "WIN"); + private final Locale locale_de = Locale.of("de"); + private final Locale locale_de_DE = Locale.of("de", "DE"); + private final Locale locale_de_DE_POSIX = Locale.of("de", "DE", "POSIX"); + private final Locale locale_de_POSIX = Locale.of("de", "", "POSIX"); + private final Locale locale_de_CH = Locale.of("de", "CH"); + + private final Locale locale_en = Locale.of("en"); + private final Locale locale_en_US = Locale.of("en", "US"); + private final Locale locale_en_US_WIN = Locale.of("en", "US", "WIN"); + private final Locale locale_en_WIN = Locale.of("en", "", "WIN"); + + private final Locale locale_fr = Locale.of("fr"); + private final Locale locale_fr_FR = Locale.of("fr", "FR"); + private final Locale locale_fr_FR_WIN = Locale.of("fr", "FR", "WIN"); + private final Locale locale_fr_WIN = Locale.of("fr", "", "WIN"); /** * diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java index fd15e29cb3c..2f2385c3696 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java @@ -108,7 +108,7 @@ void strictMatchingDoesntInvalidateNonStrictMatching() String style = null; String variation = null; - Locale locale = new Locale("nl", "NL"); + Locale locale = Locale.of("nl", "NL"); String extension = null; String filename = "org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js"; @@ -138,7 +138,7 @@ void nonStrictMatchingDoesntResultInInvalidStrictMatch() String style = null; String variation = null; - Locale locale = new Locale("nl", "NL"); + Locale locale = Locale.of("nl", "NL"); String extension = null; String filename = "org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js"; diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java index 487c19a8e15..fdecd6feab2 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/ResourceNameIteratorTest.java @@ -39,7 +39,7 @@ class ResourceNameIteratorTest extends WicketTestCase @Test void localeResourceNameIterator() { - Locale locale = new Locale("a", "b", "c"); + Locale locale = Locale.of("a", "b", "c"); LocaleResourceNameIterator iterator = new LocaleResourceNameIterator(locale, false); HashSet variations = new HashSet(); while (iterator.hasNext()) @@ -52,7 +52,7 @@ void localeResourceNameIterator() assertTrue(variations.contains("_a")); assertTrue(variations.contains("")); - locale = new Locale("a", "b"); + locale = Locale.of("a", "b"); iterator = new LocaleResourceNameIterator(locale, false); variations = new HashSet(); while (iterator.hasNext()) @@ -64,7 +64,7 @@ void localeResourceNameIterator() assertTrue(variations.contains("_a")); assertTrue(variations.contains("")); - locale = new Locale("a"); + locale = Locale.of("a"); iterator = new LocaleResourceNameIterator(locale, false); variations = new HashSet(); while (iterator.hasNext()) diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java index c369d2aa2b6..b0b7e6dc249 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/DefaultMarkupCacheKeyProviderTest.java @@ -40,36 +40,36 @@ void localeLanguageCountryVariant() Foo foo = new Foo("foo"); assertEquals("org.apache.wicket.markup.Foo.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = new Locale(""); + foo.locale = Locale.of(""); assertEquals("org.apache.wicket.markup.Foo_.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = new Locale("language"); + foo.locale = Locale.of("language"); assertEquals("org.apache.wicket.markup.Foo_language.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = new Locale("", "COUNTRY"); + foo.locale = Locale.of("", "COUNTRY"); assertEquals("org.apache.wicket.markup.Foo__COUNTRY.html", provider.getCacheKey(foo, foo.getClass())); // variant only is ignored - foo.locale = new Locale("", "", "variant"); + foo.locale = Locale.of("", "", "variant"); assertEquals("org.apache.wicket.markup.Foo_.html", provider.getCacheKey(foo, foo.getClass())); - foo.locale = new Locale("language", "COUNTRY"); + foo.locale = Locale.of("language", "COUNTRY"); assertEquals("org.apache.wicket.markup.Foo_language_COUNTRY.html", provider.getCacheKey( foo, foo.getClass())); - foo.locale = new Locale("language", "", "variant"); + foo.locale = Locale.of("language", "", "variant"); assertEquals("org.apache.wicket.markup.Foo_language__variant.html", provider.getCacheKey( foo, foo.getClass())); - foo.locale = new Locale("", "COUNTRY", "variant"); + foo.locale = Locale.of("", "COUNTRY", "variant"); assertEquals("org.apache.wicket.markup.Foo__COUNTRY_variant.html", provider.getCacheKey( foo, foo.getClass())); - foo.locale = new Locale("language", "COUNTRY", "variant"); + foo.locale = Locale.of("language", "COUNTRY", "variant"); assertEquals("org.apache.wicket.markup.Foo_language_COUNTRY_variant.html", provider.getCacheKey(foo, foo.getClass())); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java index 9d7e45b7596..0e389171ca7 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/LocalizedErrorMessageTest.java @@ -33,7 +33,7 @@ class LocalizedErrorMessageTest extends WicketTestCase @Test void wicket891() { - tester.getSession().setLocale(new Locale("nl")); + tester.getSession().setLocale(Locale.of("nl")); LocalizedMessagePage page = new LocalizedMessagePage(); tester.startPage(page); @@ -42,7 +42,7 @@ void wicket891() tester.submitForm(page.form); tester.assertErrorMessages("'Number' moet een getal zijn. "); - tester.getSession().setLocale(new Locale("us")); + tester.getSession().setLocale(Locale.of("us")); tester.clearFeedbackMessages(); @@ -62,7 +62,7 @@ void wicket891() @Test void testConvertedVars() { - tester.getSession().setLocale(new Locale("de")); + tester.getSession().setLocale(Locale.of("de")); LocalizedMessagePage page = new LocalizedMessagePage(); tester.startPage(page); @@ -84,7 +84,7 @@ void testConvertedVars() void wicket_1927() { tester.getApplication().getMarkupSettings().setDefaultMarkupEncoding("UTF-8"); - tester.getSession().setLocale(new Locale("de")); + tester.getSession().setLocale(Locale.of("de")); LocalizedMessagePage page = new LocalizedMessagePage(); tester.startPage(page); @@ -94,7 +94,7 @@ void wicket_1927() tester.submitForm(page.form); tester.assertErrorMessages("Der Wert von 'Number' ist kein g\u00FCltiger Wert f\u00FCr 'Double'."); - tester.getSession().setLocale(new Locale("pl")); + tester.getSession().setLocale(Locale.of("pl")); tester.clearFeedbackMessages(); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java index d23decda38b..bc77c7eab0a 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/ValidatorPropertiesTest.java @@ -183,7 +183,7 @@ void test1() // now test Dutch - tester.getSession().setLocale(new Locale("nl")); + tester.getSession().setLocale(Locale.of("nl")); page = new TestPage(); form = (Form)page.get("form1"); assertNotNull(form); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java index 4cebe01c9bf..eec70162e8a 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/Home.java @@ -74,7 +74,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("nl", "NL")); + getSession().setLocale(Locale.of("nl", "NL")); } }); add(new Link("goGerman") @@ -84,7 +84,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("de", "DE")); + getSession().setLocale(Locale.of("de", "DE")); } }); add(new Link("goChinese") @@ -94,7 +94,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("zh", "CN")); + getSession().setLocale(Locale.of("zh", "CN")); } }); add(new Link("goDanish") @@ -104,7 +104,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("da", "DK")); + getSession().setLocale(Locale.of("da", "DK")); } }); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java index 7e7ffae0304..0035d417975 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/form/imagebutton/ImageButtonTest.java @@ -33,7 +33,7 @@ class ImageButtonTest extends WicketTestCase @Test void imageButton() throws Exception { - Locale.setDefault(new Locale("en", "US")); + Locale.setDefault(Locale.of("en", "US")); tester.startPage(Home.class); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java index c9516c3be94..dd51c547dff 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/Home.java @@ -73,7 +73,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("nl", "NL")); + getSession().setLocale(Locale.of("nl", "NL")); } }); add(new Link("goGerman") @@ -83,7 +83,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("de", "DE")); + getSession().setLocale(Locale.of("de", "DE")); } }); add(new Link("goChinese") @@ -93,7 +93,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("zh", "CN")); + getSession().setLocale(Locale.of("zh", "CN")); } }); add(new Link("goDanish") @@ -103,7 +103,7 @@ public void onClick() @Override public void onClick() { - getSession().setLocale(new Locale("da", "DK")); + getSession().setLocale(Locale.of("da", "DK")); } }); } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java index 04e8ad94e6b..256cc372c71 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/markup/html/image/ImageTest.java @@ -34,7 +34,7 @@ public class ImageTest extends WicketTestCase @Test void test_1() throws Exception { - Locale.setDefault(new Locale("en", "US")); + Locale.setDefault(Locale.of("en", "US")); tester.startPage(Home.class); tester.clickLink("goCanadian"); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java index f289a4cf790..7ba32cc75a4 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/protocol/http/WicketFilterTest.java @@ -535,7 +535,7 @@ void ignorePaths() throws Exception filter.init(new FilterTestingConfig()); HttpServletRequest request = mock(HttpServletRequest.class); - when(request.getLocale()).thenReturn(new Locale("bg", "BG")); + when(request.getLocale()).thenReturn(Locale.of("bg", "BG")); when(request.getRequestURI()).thenReturn("/contextPath/js/bla.js") .thenReturn("/contextPath/css/bla.css") .thenReturn("/contextPath/images/bla.img") diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java b/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java index 186515d8611..8d9d300fd99 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/resource/StringResourceLoaderTestBase.java @@ -106,7 +106,7 @@ void loaderInvalidKeyNoStyleDefaultLocale() @Test void loaderValidKeyNoStyleAlternativeLocale() { - String s = loader.loadStringResource(component.getClass(), "test.string", new Locale("zz"), + String s = loader.loadStringResource(component.getClass(), "test.string", Locale.of("zz"), null, null); assertEquals("Flib flob", s, "Resource should be loaded"); } @@ -118,7 +118,7 @@ void loaderValidKeyNoStyleAlternativeLocale() void loaderInvalidKeyNoStyleAlternativeLocale() { assertNull(loader.loadStringResource(component.getClass(), "unknown.string", - new Locale("zz"), null, null), "Missing key should return null"); + Locale.of("zz"), null, null), "Missing key should return null"); } /** diff --git a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java index a2d2763e3ca..3faedccda6f 100644 --- a/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java +++ b/wicket-core/src/main/java/org/apache/wicket/core/util/resource/locator/LocaleResourceNameIterator.java @@ -63,11 +63,11 @@ public Locale getLocale() } else if (state == 2) { - return new Locale(locale.getLanguage(), locale.getCountry()); + return Locale.of(locale.getLanguage(), locale.getCountry()); } else if (state == 3) { - return new Locale(locale.getLanguage()); + return Locale.of(locale.getLanguage()); } return null; } diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java index 362fb1dd8db..3594200481e 100755 --- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java +++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java @@ -650,11 +650,11 @@ private Locale getLocale(final String value) if (bits.length > 1) { final String country = bits[1].toUpperCase(Locale.ROOT); - return new Locale(language, country); + return Locale.of(language, country); } else { - return new Locale(language); + return Locale.of(language); } } diff --git a/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java b/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java index 28ed7e2562e..2ef46d1957e 100644 --- a/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java +++ b/wicket-core/src/main/java/org/apache/wicket/resource/ResourceUtil.java @@ -196,15 +196,15 @@ public static Locale parseLocale(String locale) String parts[] = locale.toLowerCase(Locale.ROOT).split("_", 3); if (parts.length == 1) { - return new Locale(parts[0]); + return Locale.of(parts[0]); } else if (parts.length == 2) { - return new Locale(parts[0], parts[1]); + return Locale.of(parts[0], parts[1]); } else if (parts.length == 3) { - return new Locale(parts[0], parts[1], parts[2]); + return Locale.of(parts[0], parts[1], parts[2]); } else { diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java b/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java index 8833c456ee3..4bab3e24177 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/forminput/FormInputApplication.java @@ -40,9 +40,9 @@ public class FormInputApplication extends WicketExampleApplication { /** Relevant locales wrapped in a list. */ public static final List LOCALES = Arrays.asList(Locale.ENGLISH, - new Locale("nl", "NL"), Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, - new Locale("pt", "BR"), new Locale("fa", "IR"), new Locale("da", "DK"), - new Locale("th", "TH"), new Locale("ru"), new Locale("ko", "KR")); + Locale.of("nl", "NL"), Locale.GERMAN, Locale.SIMPLIFIED_CHINESE, Locale.JAPANESE, + Locale.of("pt", "BR"), Locale.of("fa", "IR"), Locale.of("da", "DK"), + Locale.of("th", "TH"), Locale.of("ru"), Locale.of("ko", "KR")); @Override public Class getHomePage() @@ -92,7 +92,7 @@ protected void init() // Persian buttons Font fontFa = new Font("Serif", Font.BOLD, 16); - Locale farsi = new Locale("fa", "IR"); + Locale farsi = Locale.of("fa", "IR"); DefaultButtonImageResource imgSaveFa = new DefaultButtonImageResource( "\u0630\u062e\u064a\u0631\u0647"); imgSaveFa.setFont(fontFa); diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java b/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java index 6d6d3f111c8..c4bcdbb9d8c 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/pub/Home.java @@ -68,12 +68,12 @@ public Home(final PageParameters parameters) // locale add(new SetLocaleLink("goCanadian", Locale.CANADA)); add(new SetLocaleLink("goUS", Locale.US)); - add(new SetLocaleLink("goDutch", new Locale("nl", "NL"))); - add(new SetLocaleLink("goGerman", new Locale("de", "DE"))); - add(new SetLocaleLink("goChinese", new Locale("zh", "CN"))); - add(new SetLocaleLink("goDanish", new Locale("da", "DK"))); - add(new SetLocaleLink("goKorean", new Locale("ko", "KR"))); - add(new SetLocaleLink("goHungarian", new Locale("hu"))); + add(new SetLocaleLink("goDutch", Locale.of("nl", "NL"))); + add(new SetLocaleLink("goGerman", Locale.of("de", "DE"))); + add(new SetLocaleLink("goChinese", Locale.of("zh", "CN"))); + add(new SetLocaleLink("goDanish", Locale.of("da", "DK"))); + add(new SetLocaleLink("goKorean", Locale.of("ko", "KR"))); + add(new SetLocaleLink("goHungarian", Locale.of("hu"))); } private static class SetLocaleLink extends Link { diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java b/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java index 088400c9235..13d7010836f 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/pub2/Home.java @@ -64,12 +64,12 @@ public Home(final PageParameters parameters) // locale add(new SetLocaleLink("goCanadian", Locale.CANADA)); add(new SetLocaleLink("goUS", Locale.US)); - add(new SetLocaleLink("goDutch", new Locale("nl", "NL"))); - add(new SetLocaleLink("goGerman", new Locale("de", "DE"))); - add(new SetLocaleLink("goChinese", new Locale("zh", "CN"))); - add(new SetLocaleLink("goDanish", new Locale("da", "DK"))); - add(new SetLocaleLink("goKorean", new Locale("ko", "KR"))); - add(new SetLocaleLink("goHungarian", new Locale("hu"))); + add(new SetLocaleLink("goDutch", Locale.of("nl", "NL"))); + add(new SetLocaleLink("goGerman", Locale.of("de", "DE"))); + add(new SetLocaleLink("goChinese", Locale.of("zh", "CN"))); + add(new SetLocaleLink("goDanish", Locale.of("da", "DK"))); + add(new SetLocaleLink("goKorean", Locale.of("ko", "KR"))); + add(new SetLocaleLink("goHungarian", Locale.of("hu"))); } private static class SetLocaleLink extends Link { diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java b/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java index e16399aadba..040c4da7e90 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java @@ -37,13 +37,13 @@ static Locale parseLocale(final String localeAsString, final Locale defaultLocal { String lang = localeAsString.substring(0, idxOfUnderbar); String country = localeAsString.substring(idxOfUnderbar + 1); - result = new Locale(lang, country); + result = Locale.of(lang, country); } else { String lang = localeAsString; - result = new Locale(lang); + result = Locale.of(lang); } return result; diff --git a/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java b/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java index 59ee9dda870..30446adaf39 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/resource/ResourceUtils.java @@ -138,7 +138,7 @@ public static PathLocale getLocaleFromFilename(String path) String basePath = path.substring(0, languagePos) + (min == null ? "" : min) + extension; - Locale locale = new Locale(language, country != null ? country : "", + Locale locale = Locale.of(language, country != null ? country : "", variant != null ? variant : ""); return new PathLocale(basePath, locale); diff --git a/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java b/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java index e09c64523e7..01141650f0b 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/convert/converters/ConvertersTest.java @@ -50,7 +50,7 @@ final class ConvertersTest { /** Dutch locale for localized testing. */ - private static final Locale DUTCH_LOCALE = new Locale("nl", "NL"); + private static final Locale DUTCH_LOCALE = Locale.of("nl", "NL"); @Test void thousandSeparator() { From 74a0b271b537abf892a388f527753b8c1bd05c3d Mon Sep 17 00:00:00 2001 From: Peter Major Date: Wed, 27 Nov 2024 14:50:46 +0000 Subject: [PATCH 2/3] Migrate new URL constructor invocations to URI#toURL --- .../wicket/core/util/file/WebApplicationPathTest.java | 3 ++- .../wicket/core/util/resource/UrlResourceStreamTest.java | 3 ++- .../resource/locator/CachingResourceStreamLocatorTest.java | 3 ++- .../java/org/apache/wicket/markup/html/include/Include.java | 6 ++++-- .../test/java/org/apache/wicket/util/file/FilesTest.java | 3 ++- .../java/org/apache/wicket/util/io/ConnectionsTest.java | 4 +++- .../java/org/apache/wicket/util/io/LastModifiedTest.java | 5 +++-- 7 files changed, 18 insertions(+), 9 deletions(-) diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java index d8badb3812a..e1642de1507 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/file/WebApplicationPathTest.java @@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; +import java.net.URI; import java.net.URL; import jakarta.servlet.ServletContext; @@ -35,7 +36,7 @@ class WebApplicationPathTest @Test void doNotServeResourcesFromWebInf() throws Exception { - URL webUrl = new URL("file://dummyFile"); + URL webUrl = URI.create("file://dummyFile").toURL(); ServletContext context = Mockito.mock(ServletContext.class); Mockito.when(context.getResource(ArgumentMatchers.any(String.class))).thenReturn(webUrl); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java index 60829c9b05d..f6725f37947 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/UrlResourceStreamTest.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.InputStream; +import java.net.URI; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; @@ -66,7 +67,7 @@ void loadJustOnce() throws IOException, ResourceStreamNotFoundException { final AtomicInteger connectCounter = new AtomicInteger(0); final AtomicInteger streamCounter = new AtomicInteger(0); - URL url = new URL(null, "test://anything", new CountingURLStreamHandler(realURL, + URL url = URL.of(URI.create("test://anything"), new CountingURLStreamHandler(realURL, connectCounter, streamCounter)); UrlResourceStream countingStream = new UrlResourceStream(url); diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java index 2f2385c3696..0ede019f760 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/core/util/resource/locator/CachingResourceStreamLocatorTest.java @@ -24,6 +24,7 @@ import static org.mockito.Mockito.when; import java.io.File; +import java.net.URI; import java.net.URL; import java.util.Locale; @@ -218,7 +219,7 @@ void urlResource() throws Exception { IResourceStreamLocator resourceStreamLocator = mock(IResourceStreamLocator.class); - UrlResourceStream urs = new UrlResourceStream(new URL("file:///")); + UrlResourceStream urs = new UrlResourceStream(URI.create("file:///").toURL()); when(resourceStreamLocator.locate(String.class, "path")).thenReturn(urs); diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java index 1d1ee4bd4d3..ee44fd3b877 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/include/Include.java @@ -17,6 +17,8 @@ package org.apache.wicket.markup.html.include; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.Charset; @@ -187,9 +189,9 @@ private String importAbsoluteUrl(CharSequence url) { try { - return importUrl(new URL(url.toString())); + return importUrl(new URI(url.toString()).toURL()); } - catch (MalformedURLException e) + catch (URISyntaxException | MalformedURLException e) { throw new WicketRuntimeException(e); } diff --git a/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java b/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java index 30de8724ce8..f4c42967881 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/file/FilesTest.java @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test; import java.io.IOException; +import java.net.URI; import java.net.URL; import static java.lang.System.currentTimeMillis; @@ -233,7 +234,7 @@ public void removeFolderAsync() throws Exception @Test public void fileWithWhitespace() throws Exception { - URL url = new URL("file:/file%20with%20whitespace"); + URL url = URI.create("file:/file%20with%20whitespace").toURL(); assertEquals(java.io.File.separator + "file with whitespace", Files.getLocalFileFromUrl(url).getPath()); diff --git a/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java b/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java index 02601b371f8..0ac25887fef 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/io/ConnectionsTest.java @@ -18,6 +18,8 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.net.URI; import java.net.URL; import java.time.Instant; import org.apache.wicket.util.WicketTestTag; @@ -36,7 +38,7 @@ class ConnectionsTest @Test void getLastModified() throws Exception { - URL url = new URL("https://wicket.apache.org/learn/books/wia.png"); + URL url = URI.create("https://wicket.apache.org/learn/books/wia.png").toURL(); Instant lastModified = Connections.getLastModified(url); assertNotNull(lastModified); assertNotEquals(0L, lastModified.toEpochMilli()); diff --git a/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java b/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java index 2ed37103acf..55b5df4a287 100644 --- a/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java +++ b/wicket-util/src/test/java/org/apache/wicket/util/io/LastModifiedTest.java @@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.IOException; +import java.net.URI; import java.net.URL; import java.time.Instant; import org.apache.wicket.util.file.Files; @@ -43,7 +44,7 @@ public void getTimestampForMissingFile() throws IOException { File file = new File("/does/not/exists/4iorp4opergere.txt"); assertNull(Files.getLastModified(file)); - assertNull(Connections.getLastModified(new URL("file:" + file.getAbsolutePath()))); + assertNull(Connections.getLastModified(URI.create("file:" + file.getAbsolutePath()).toURL())); } /** @@ -85,7 +86,7 @@ public void getLastModified() throws IOException final Instant expected = Instant.ofEpochMilli(lm); assertEquals(expected, Files.getLastModified(file)); assertEquals(expected, - Connections.getLastModified(new URL("file:" + file.getAbsolutePath()))); + Connections.getLastModified(URI.create("file:" + file.getAbsolutePath()).toURL())); } } finally From 92505c9b8ef457cdf29e86e574486abd954728d5 Mon Sep 17 00:00:00 2001 From: Peter Major Date: Wed, 27 Nov 2024 14:52:54 +0000 Subject: [PATCH 3/3] Migrate deprecated API calls to their replacements --- .../wicket/pageStore/AsynchronousPageStoreTest.java | 3 +-- .../InSessionPageStoreConcurrencyTest.java | 2 +- .../wicket/request/resource/PartWriterCallback.java | 13 +++++++------ .../java/org/apache/wicket/util/lang/Threads.java | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java index ffd85e5020e..5c1577ee10a 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/AsynchronousPageStoreTest.java @@ -26,7 +26,6 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.lang3.RandomUtils; @@ -534,6 +533,6 @@ public IManageablePage getPage(IPageContext context, int id) { private long around(long target) { - return RandomUtils.nextLong((long)(target * .9), (long)(target * 1.1)); + return RandomUtils.secure().randomLong((long)(target * .9), (long)(target * 1.1)); } } diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java index 75594096e25..acd43f8dad4 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/pageStore/InSessionPageStoreConcurrencyTest.java @@ -96,7 +96,7 @@ public MockHttpSession getHttpSession() }; Callable serializeSessionTask = () -> { - final NullOutputStream nullOutputStream = NullOutputStream.NULL_OUTPUT_STREAM; + final NullOutputStream nullOutputStream = NullOutputStream.INSTANCE; try(final ObjectOutputStream objectOutputStream = new ObjectOutputStream(nullOutputStream)) { objectOutputStream.writeObject(wicketTester.getSession()); diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java index 6b6b4c9a6a8..8e2ce385452 100644 --- a/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java +++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/PartWriterCallback.java @@ -141,12 +141,13 @@ public void writeData(Attributes attributes) throws IOException { // Stream is going to be read from the starting point next to the skipped bytes // till the end byte computed by the range between startbyte / endbyte - boundedInputStream = new BoundedInputStream(inputStream, - (endbyte - startbyte) + 1); - - // The original input stream is going to be closed by the end of the request - // so set propagate close to false - boundedInputStream.setPropagateClose(false); + boundedInputStream = BoundedInputStream.builder() + .setInputStream(inputStream) + .setMaxCount((endbyte - startbyte) + 1) + // The original input stream is going to be closed by the end of the request + // so set propagate close to false + .setPropagateClose(false) + .get(); // The read bytes in the current buffer int readBytes; diff --git a/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java b/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java index 7f0ffdc1276..1d1e765551e 100644 --- a/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java +++ b/wicket-util/src/main/java/org/apache/wicket/util/lang/Threads.java @@ -106,7 +106,7 @@ private static void dumpSingleThread(Logger logger, Thread thread, StackTraceEle variables.put("name", thread.getName()); variables.put("isDaemon", thread.isDaemon() ? " daemon" : ""); variables.put("priority", thread.getPriority()); - variables.put("threadIdDec", thread.getId()); + variables.put("threadIdDec", thread.threadId()); variables.put("state", thread.getState()); ThreadDump throwable = new ThreadDump();