This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 4.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 91a08affe213f119871d362f015c631ab0208e89
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
AuthorDate: Mon Jun 15 09:01:26 2026 -0400
Bump net.sourceforge.pmd:pmd-java from 7.24.0 to 7.25.0 (#3197)
* Bump net.sourceforge.pmd:pmd-java from 7.24.0 to 7.25.0
Bumps [net.sourceforge.pmd:pmd-java](https://github.com/pmd/pmd) from
7.24.0 to 7.25.0.
- [Release notes](https://github.com/pmd/pmd/releases)
-
[Commits](https://github.com/pmd/pmd/compare/pmd_releases/7.24.0...pmd_releases/7.25.0)
---
updated-dependencies:
- dependency-name: net.sourceforge.pmd:pmd-java
dependency-version: 7.25.0
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <[email protected]>
* Fix PMD violations
---------
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot]
<49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Andriy Redko <[email protected]>
(cherry picked from commit a6d8bd3cb10586741cb19b357a82af4f6f88390d)
# Conflicts:
#
systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
#
systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore2.java
#
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabilityTest.java
#
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsWebObservabilityTest.java
#
systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsObservabilityTest.java
#
systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/jaxrs/BookServerAsyncClient.java
---
.../main/java/org/apache/cxf/attachment/.gitignore | 1 +
.../org/apache/cxf/common/util/StreamPrinter.java | 1 +
.../java/org/apache/cxf/helpers/FileUtils.java | 14 +--
.../cxf/workqueue/AutomaticWorkQueueImpl.java | 1 +
.../cxf/workqueue/AutomaticWorkQueueTest.java | 1 +
.../micrometer/ObservationIntegrationTest.java | 2 +-
parent/pom.xml | 2 +-
.../cxf/jaxrs/provider/BinaryDataProviderTest.java | 3 +-
.../jaxrs/provider/FormEncodingProviderTest.java | 4 +-
.../jaxrs/provider/JAXBElementProviderTest.java | 2 +-
.../jaxrs/provider/PrimitiveTextProviderTest.java | 6 +-
.../java/org/apache/cxf/jaxws/JaxWsClientTest.java | 32 +++----
.../jaxws/context/WebServiceContextImplTest.java | 21 ++---
.../cxf/endpoint/dynamic/DynamicClientFactory.java | 12 +--
.../java/org/apache/cxf/frontend/WSDLGetUtils.java | 48 +++-------
.../apache/cxf/javascript/JsXMLHttpRequest.java | 16 ++--
.../apache/cxf/javascript/fortest/MtoMImpl.java | 3 +-
.../fortest/MtoMParameterBeanNoDataHandler.java | 12 +--
.../cxf/jaxrs/client/ThreadLocalClientState.java | 1 +
.../provider/aegis/AegisElementProviderTest.java | 13 +--
.../http/asyncclient/AsyncHTTPConduitFactory.java | 1 +
.../asyncclient/hc5/AsyncHTTPConduitFactory.java | 1 +
.../transport/http/DestinationRegistryImpl.java | 22 ++---
.../cxf/transport/websocket/WebSocketUtils.java | 3 +-
.../jetty12/Jetty12WebSocketDestination.java | 10 +-
.../cxf/wsdl/service/factory/ClassReader.java | 5 +-
.../apache/cxf/wsdl11/WSDLServiceBuilderTest.java | 5 +-
.../org/apache/cxf/wsn/jms/JmsSubscription.java | 1 +
.../cxf/systest/jaxrs/BookServerAsyncClient.java | 3 +-
.../apache/cxf/systest/jaxrs/BookStoreSpring.java | 5 +-
.../jaxrs/JAXRSClientServerSpringBookTest.java | 6 +-
.../reactive/AbstractCompletableFutureServer.java | 3 +-
.../org/apache/cxf/systest/jaxws/JAXWSServer.java | 40 ++++----
.../apache/cxf/systest/jaxrs/sse/BookStore.java | 104 ++++++++++-----------
.../apache/cxf/systest/jaxrs/sse/BookStore2.java | 91 ++++++++----------
.../spring/boot/SpringClientOnlyJaxrsTest.java | 6 +-
.../spring/boot/SpringJaxrsApplicationTest.java | 22 ++---
.../boot/SpringJaxrsClassesScanningTest.java | 4 +-
.../boot/SpringJaxrsComponentScanningTest.java | 4 +-
.../spring/boot/SpringJaxrsObservabilityTest.java | 4 +-
.../systest/jaxrs/spring/boot/SpringJaxrsTest.java | 20 ++--
.../boot/SpringJaxrsWebObservabilityTest.java | 4 +-
.../jaxrs/spring/boot/SpringSseEmitterTest.java | 4 +-
.../spring/boot/SpringJaxwsInjectionTest.java | 4 +-
.../spring/boot/SpringJaxwsObservabilityTest.java | 4 +-
.../systest/jaxws/spring/boot/SpringJaxwsTest.java | 19 ++--
.../jaxws/spring/boot/SpringJaxwsTimedTest.java | 7 +-
.../spring/boot/ssl/SpringClientSslBundleTest.java | 7 +-
.../systest/hc5/jaxrs/BookServerAsyncClient.java | 3 +-
.../systest/hc/jaxrs/BookServerAsyncClient.java | 3 +-
.../http/auth/DigestAuthSupplierJettyTest.java | 2 +-
.../http/auth/DigestAuthSupplierSpringTest.java | 4 +-
.../apache/cxf/systest/mtom/ClientMtomXopTest.java | 2 +-
.../apache/cxf/systest/type_test/I18NStrings.java | 6 +-
.../systest/ws/addr_fromjava/WSAFromJavaTest.java | 19 +---
.../systest/ws/addr_fromwsdl/WSAFromWSDLTest.java | 19 +---
.../apache/cxf/testutil/common/ServerLauncher.java | 1 +
.../corba/idlpreprocessor/IncludeStackEntry.java | 3 +-
.../idlpreprocessor/IdlPreprocessorReaderTest.java | 3 +-
.../tools/validator/internal/ValidatorUtil.java | 3 +-
60 files changed, 293 insertions(+), 379 deletions(-)
diff --git a/core/src/main/java/org/apache/cxf/attachment/.gitignore
b/core/src/main/java/org/apache/cxf/attachment/.gitignore
new file mode 100644
index 00000000000..12ef6878e36
--- /dev/null
+++ b/core/src/main/java/org/apache/cxf/attachment/.gitignore
@@ -0,0 +1 @@
+/AttachmentUtil.java
diff --git a/core/src/main/java/org/apache/cxf/common/util/StreamPrinter.java
b/core/src/main/java/org/apache/cxf/common/util/StreamPrinter.java
index 564c64cc487..f00c70a62b3 100644
--- a/core/src/main/java/org/apache/cxf/common/util/StreamPrinter.java
+++ b/core/src/main/java/org/apache/cxf/common/util/StreamPrinter.java
@@ -26,6 +26,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
+@SuppressWarnings("PMD.OverridingThreadRun")
class StreamPrinter extends Thread {
private InputStream is;
private String msg;
diff --git a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
index 5d1fc10ea42..18a330da139 100644
--- a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
@@ -89,12 +89,7 @@ public final class FileUtils {
if (shutdownHook != null) {
Runtime.getRuntime().removeShutdownHook(shutdownHook);
}
- shutdownHook = new Thread() {
- @Override
- public void run() {
- removeDir(defaultTempDir, true);
- }
- };
+ shutdownHook = new Thread(() -> removeDir(defaultTempDir, true));
Runtime.getRuntime().addShutdownHook(shutdownHook);
}
@@ -175,12 +170,7 @@ public final class FileUtils {
}
if (addHook) {
final File f2 = newTmpDir;
- Thread hook = new Thread() {
- @Override
- public void run() {
- removeDir(f2, true);
- }
- };
+ Thread hook = new Thread(() -> removeDir(f2, true));
Runtime.getRuntime().addShutdownHook(hook);
}
return newTmpDir;
diff --git
a/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
b/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
index 2478fb9ce56..fb58f0eb25c 100644
--- a/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
+++ b/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
@@ -287,6 +287,7 @@ public class AutomaticWorkQueueImpl implements
AutomaticWorkQueue {
}
+ @SuppressWarnings("PMD.OverridingThreadRun")
class WatchDog extends Thread {
DelayQueue<DelayedTaskWrapper> delayQueue;
AtomicBoolean shutdown = new AtomicBoolean(false);
diff --git
a/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
b/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
index f9c3af30a67..35c5a016c7a 100644
--- a/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
+++ b/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
@@ -489,6 +489,7 @@ public class AutomaticWorkQueueTest {
void workItemCompleted(String name);
}
+ @SuppressWarnings("PMD.OverridingThreadRun")
public static class DeadLockThread extends Thread implements Callback {
public static final long DEFAULT_WORK_TIME = 10L;
public static final int DEFAULT_WORK_ITEMS = 200;
diff --git
a/integration/tracing/tracing-micrometer/src/test/java/org/apache/cxf/tracing/micrometer/ObservationIntegrationTest.java
b/integration/tracing/tracing-micrometer/src/test/java/org/apache/cxf/tracing/micrometer/ObservationIntegrationTest.java
index 8551dfffd9d..4f9e48c3687 100644
---
a/integration/tracing/tracing-micrometer/src/test/java/org/apache/cxf/tracing/micrometer/ObservationIntegrationTest.java
+++
b/integration/tracing/tracing-micrometer/src/test/java/org/apache/cxf/tracing/micrometer/ObservationIntegrationTest.java
@@ -34,7 +34,7 @@ import io.micrometer.tracing.test.simple.SpansAssert;
import org.junit.jupiter.api.AfterEach;
-public class ObservationIntegrationTest extends SampleTestRunner {
+class ObservationIntegrationTest extends SampleTestRunner {
private static final String ADDRESS = "http://localhost:9282";
private Server server;
diff --git a/parent/pom.xml b/parent/pom.xml
index 4a766e23ed7..38e000b3a3e 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -438,7 +438,7 @@
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-java</artifactId>
- <version>7.24.0</version>
+ <version>7.25.0</version>
</dependency>
</dependencies>
<configuration>
diff --git
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
index 81f19b4379e..02d648c0971 100644
---
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
+++
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BinaryDataProviderTest.java
@@ -28,6 +28,7 @@ import java.io.OutputStream;
import java.io.Reader;
import java.io.StringReader;
import java.lang.annotation.Annotation;
+import java.nio.charset.StandardCharsets;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.StreamingOutput;
@@ -101,7 +102,7 @@ public class BinaryDataProviderTest {
@Test
public void testReadBytesFromUtf8() throws Exception {
MessageBodyReader p = new BinaryDataProvider();
- byte[] utf8Bytes = "世界ーファイル".getBytes("UTF-16");
+ byte[] utf8Bytes = "世界ーファイル".getBytes(StandardCharsets.UTF_16);
byte[] readBytes = (byte[])p.readFrom(byte[].class, byte[].class, new
Annotation[]{},
MediaType.APPLICATION_OCTET_STREAM_TYPE,
new MetadataMap<String, Object>(),
diff --git
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java
index c103bf6bd24..176c8ddfec2 100644
---
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java
+++
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java
@@ -301,8 +301,8 @@ public class FormEncodingProviderTest {
String eWithAcute = "\u00E9";
String helloStringUTF16 = "name=F" + eWithAcute + "lix";
- byte[] iso88591bytes = helloStringUTF16.getBytes("ISO-8859-1");
- String helloStringISO88591 = new String(iso88591bytes, "ISO-8859-1");
+ byte[] iso88591bytes =
helloStringUTF16.getBytes(StandardCharsets.ISO_8859_1);
+ String helloStringISO88591 = new String(iso88591bytes,
StandardCharsets.ISO_8859_1);
@SuppressWarnings("rawtypes")
FormEncodingProvider<MultivaluedMap> ferp
= new FormEncodingProvider<>();
diff --git
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
index e24945e8498..3a337546b00 100644
---
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
+++
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
@@ -117,7 +117,7 @@ public class JAXBElementProviderTest {
String bookStringUTF16 = "<?xml version=\"1.0\"
encoding=\"ISO-8859-1\"?>"
+ "<Book><name>" + nameStringUTF16 +
"</name></Book>";
- byte[] iso88591bytes = bookStringUTF16.getBytes("ISO-8859-1");
+ byte[] iso88591bytes =
bookStringUTF16.getBytes(StandardCharsets.ISO_8859_1);
JAXBElementProvider<Book> p = new JAXBElementProvider<>();
Book book = p.readFrom(Book.class, null,
diff --git
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProviderTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProviderTest.java
index bde2dca5f76..80fd81dff3c 100644
---
a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProviderTest.java
+++
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProviderTest.java
@@ -194,10 +194,10 @@ public class PrimitiveTextProviderTest {
String.class, String.class, null,
MediaType.valueOf("text/plain;charset=ISO-8859-1"),
headers, os);
- byte[] iso88591bytes = helloStringUTF16.getBytes("ISO-8859-1");
- String helloStringISO88591 = new String(iso88591bytes, "ISO-8859-1");
+ byte[] iso88591bytes =
helloStringUTF16.getBytes(StandardCharsets.ISO_8859_1);
+ String helloStringISO88591 = new String(iso88591bytes,
StandardCharsets.ISO_8859_1);
- assertEquals(helloStringISO88591, os.toString("ISO-8859-1"));
+ assertEquals(helloStringISO88591,
os.toString(StandardCharsets.ISO_8859_1));
}
@Test
diff --git
a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
index 280f547d327..9c563cb37fa 100644
--- a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
+++ b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/JaxWsClientTest.java
@@ -150,15 +150,13 @@ public class JaxWsClientTest extends AbstractJaxWsTest {
requestContext.put(key, "ho");
final Object[] result = new Object[2];
- Thread t = new Thread() {
- public void run() {
- //requestContext in main thread shouldn't affect the
requestContext in this thread
- Map<String, Object> requestContext =
((BindingProvider)handler).getRequestContext();
- result[0] = requestContext.get(key);
- requestContext.remove(key);
- result[1] = requestContext.get(key);
- }
- };
+ Thread t = new Thread(() -> {
+ //requestContext in main thread shouldn't affect the
requestContext in this thread
+ Map<String, Object> rc =
((BindingProvider)handler).getRequestContext();
+ result[0] = rc.get(key);
+ rc.remove(key);
+ result[1] = rc.get(key);
+ });
t.start();
t.join();
@@ -190,15 +188,13 @@ public class JaxWsClientTest extends AbstractJaxWsTest {
requestContext.put(key, "ho");
final Object[] result = new Object[2];
- Thread t = new Thread() {
- public void run() {
- //requestContext in main thread shouldn't affect the
requestContext in this thread
- Map<String, Object> requestContext = disp.getRequestContext();
- result[0] = requestContext.get(key);
- requestContext.remove(key);
- result[1] = requestContext.get(key);
- }
- };
+ Thread t = new Thread(() -> {
+ //requestContext in main thread shouldn't affect the
requestContext in this thread
+ Map<String, Object> rc = disp.getRequestContext();
+ result[0] = rc.get(key);
+ rc.remove(key);
+ result[1] = rc.get(key);
+ });
t.start();
t.join();
diff --git
a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
index a9b790677d4..0c058a2507c 100644
---
a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
+++
b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WebServiceContextImplTest.java
@@ -56,22 +56,19 @@ public class WebServiceContextImplTest {
assertSame(ctx, wsci.getMessageContext());
- Thread t = new Thread() {
- public void run() {
- WebServiceContextImpl threadLocalWSCI = new
WebServiceContextImpl();
+ Thread t = new Thread(() -> {
+ WebServiceContextImpl threadLocalWSCI = new
WebServiceContextImpl();
- assertNull(threadLocalWSCI.getMessageContext());
+ assertNull(threadLocalWSCI.getMessageContext());
- MessageImpl msg1 = new MessageImpl();
- MessageContext threadLocalCtx = new
WrappedMessageContext(msg1);
- WebServiceContextImpl.setMessageContext(threadLocalCtx);
+ MessageImpl msg1 = new MessageImpl();
+ MessageContext threadLocalCtx = new WrappedMessageContext(msg1);
+ WebServiceContextImpl.setMessageContext(threadLocalCtx);
- assertSame(threadLocalCtx,
threadLocalWSCI.getMessageContext());
- assertTrue(ctx != threadLocalWSCI.getMessageContext());
-
- }
- };
+ assertSame(threadLocalCtx, threadLocalWSCI.getMessageContext());
+ assertTrue(ctx != threadLocalWSCI.getMessageContext());
+ });
t.start();
diff --git
a/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
b/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
index ad286708543..c19b3f116f9 100644
---
a/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
+++
b/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
@@ -21,7 +21,6 @@ package org.apache.cxf.endpoint.dynamic;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -31,6 +30,7 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
@@ -687,14 +687,10 @@ public class DynamicClientFactory {
if (url.getProtocol().startsWith("file")) {
File file = null;
// CXF-3884 use url-decoder to get the decoded file
path from the url
- try {
- if (url.getPath() == null) {
- continue;
- }
- file = new File(URLDecoder.decode(url.getPath(),
"utf-8"));
- } catch (UnsupportedEncodingException uee) {
- // ignored as utf-8 is supported
+ if (url.getPath() == null) {
+ continue;
}
+ file = new File(URLDecoder.decode(url.getPath(),
StandardCharsets.UTF_8));
if (null != file && file.exists()) {
classPath.append(file.getAbsolutePath())
diff --git
a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
index e724e4a5f2c..beac0c02ba5 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetUtils.java
@@ -25,6 +25,7 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
@@ -147,10 +148,10 @@ public class WSDLGetUtils {
//
if (params.containsKey("wsdl")) {
- String wsdl = URLDecoder.decode(params.get("wsdl"), "utf-8");
+ String wsdl = URLDecoder.decode(params.get("wsdl"),
StandardCharsets.UTF_8);
doc = writeWSDLDocument(message, mp, smp, wsdl, base,
endpointInfo);
} else if (params.get("xsd") != null) {
- String xsd = URLDecoder.decode(params.get("xsd"), "utf-8");
+ String xsd = URLDecoder.decode(params.get("xsd"),
StandardCharsets.UTF_8);
doc = readXSDDocument(bus, xsd, smp, base);
updateDoc(doc, base, mp, smp, message, xsd);
}
@@ -175,11 +176,11 @@ public class WSDLGetUtils {
// resolve requested location with relative import path
key = new URI(xsd).resolve(loc).toString();
- SchemaReference ref = smp.get(URLDecoder.decode(key, "utf-8"));
+ SchemaReference ref = smp.get(URLDecoder.decode(key,
StandardCharsets.UTF_8));
if (ref == null) {
// if the result is not known, check if we can resolve it
into something known
String resolved =
resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus), key, base);
- if (resolved != null &&
smp.containsKey(URLDecoder.decode(resolved, "utf-8"))) {
+ if (resolved != null &&
smp.containsKey(URLDecoder.decode(resolved, StandardCharsets.UTF_8))) {
// if it is resolvable, we can use it
return base + "?xsd=" + key.replace(" ", "%20");
}
@@ -190,20 +191,20 @@ public class WSDLGetUtils {
} catch (URISyntaxException e) {
//ignore
}
- SchemaReference ref = smp.get(URLDecoder.decode(key, "utf-8"));
+ SchemaReference ref = smp.get(URLDecoder.decode(key,
StandardCharsets.UTF_8));
if (ref == null && resolvedXsd != null) {
try {
String key2 = new URI(resolvedXsd).resolve(loc).toString();
- SchemaReference ref2 = smp.get(URLDecoder.decode(key2,
"utf-8"));
+ SchemaReference ref2 = smp.get(URLDecoder.decode(key2,
StandardCharsets.UTF_8));
if (ref2 == null) {
// if the result is not known, check if we can resolve it
into something known
String resolved =
resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus), key2, base);
- if (resolved != null &&
smp.containsKey(URLDecoder.decode(resolved, "utf-8"))) {
+ if (resolved != null &&
smp.containsKey(URLDecoder.decode(resolved, StandardCharsets.UTF_8))) {
// if it is resolvable, we can use it
- ref = smp.get(URLDecoder.decode(resolved, "utf-8"));
+ ref = smp.get(URLDecoder.decode(resolved,
StandardCharsets.UTF_8));
}
} else {
- ref = smp.get(URLDecoder.decode(key2, "utf-8"));
+ ref = smp.get(URLDecoder.decode(key2,
StandardCharsets.UTF_8));
}
} catch (URISyntaxException e) {
//ignore, ref can remain null
@@ -285,7 +286,7 @@ public class WSDLGetUtils {
} catch (URISyntaxException e) {
//ignore
}
- if (mp.containsKey(URLDecoder.decode(sl, "utf-8"))) {
+ if (mp.containsKey(URLDecoder.decode(sl,
StandardCharsets.UTF_8))) {
el.setAttribute("location", base + "?wsdl=" + sl.replace("
", "%20"));
}
}
@@ -396,19 +397,9 @@ public class WSDLGetUtils {
List<Import> impLst = CastUtils.cast(lst);
for (Import imp : impLst) {
String start = imp.getLocationURI();
- String decodedStart;
// Always use the URL decoded version to ensure that we have a
// canonical representation of the import URL for lookup.
-
- try {
- decodedStart = URLDecoder.decode(start, "utf-8");
- } catch (UnsupportedEncodingException e) {
- throw new WSDLQueryException(
- new
org.apache.cxf.common.i18n.Message("COULD_NOT_PROVIDE_WSDL",
- LOG,
- start), e);
- }
-
+ String decodedStart = URLDecoder.decode(start,
StandardCharsets.UTF_8);
String resolvedSchemaLocation = resolveWithCatalogs(catalogs,
start, base);
if (resolvedSchemaLocation == null) {
@@ -418,7 +409,7 @@ public class WSDLGetUtils {
} catch (MalformedURLException e) {
try {
start = getLocationURI(start, docBase);
- decodedStart = URLDecoder.decode(start, "utf-8");
+ decodedStart = URLDecoder.decode(start,
StandardCharsets.UTF_8);
} catch (Exception e1) {
//ignore
}
@@ -538,19 +529,10 @@ public class WSDLGetUtils {
String origLocation = schemaReference.getSchemaLocationURI();
if (start != null) {
- String decodedStart;
- String decodedOrigLocation;
// Always use the URL decoded version to ensure that we have a
// canonical representation of the import URL for lookup.
- try {
- decodedStart = URLDecoder.decode(start, "utf-8");
- decodedOrigLocation = URLDecoder.decode(origLocation, "utf-8");
- } catch (UnsupportedEncodingException e) {
- throw new WSDLQueryException(
- new
org.apache.cxf.common.i18n.Message("COULD_NOT_PROVIDE_WSDL",
- LOG,
- start), e);
- }
+ String decodedStart = URLDecoder.decode(start,
StandardCharsets.UTF_8);
+ String decodedOrigLocation = URLDecoder.decode(origLocation,
StandardCharsets.UTF_8);
final SchemaReference doneSchema = doneSchemas.get(decodedStart);
if (doneSchema == null ||
!doneSchema.getSchemaLocationURI().equals(
diff --git
a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
index d414189387d..7041f6fe1ab 100644
---
a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
+++
b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
@@ -325,16 +325,14 @@ public class JsXMLHttpRequest extends ScriptableObject {
notifyReadyStateChangeListener();
if (storedAsync) {
- new Thread() {
- public void run() {
- try {
- Context cx = ContextFactory.getGlobal().enterContext();
- communicate(cx);
- } finally {
- Context.exit();
- }
+ new Thread(() -> {
+ try {
+ Context cx = ContextFactory.getGlobal().enterContext();
+ communicate(cx);
+ } finally {
+ Context.exit();
}
- } .start();
+ }).start();
} else {
communicate(Context.getCurrentContext());
}
diff --git
a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java
b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java
index c8f28664e88..6a86b56a2bb 100644
---
a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java
+++
b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/fortest/MtoMImpl.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
import jakarta.activation.DataHandler;
import jakarta.jws.WebService;
@@ -45,7 +46,7 @@ public class MtoMImpl implements MtoM {
InputStream someData =
getClass().getClassLoader().getResourceAsStream("org/apache/cxf/javascript/cxf-utils.js");
try (StringWriter sw = new StringWriter()) {
- InputStreamReader isr = new InputStreamReader(someData, "utf-8");
+ InputStreamReader isr = new InputStreamReader(someData,
StandardCharsets.UTF_8);
IOUtils.copy(isr, sw, 4096);
returnData = sw.toString();
} catch (IOException e) {
diff --git
a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java
b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java
index 41dffe7bcea..50fd93ca6cf 100644
---
a/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java
+++
b/rt/javascript/javascript-tests/src/test/java/org/apache/cxf/javascript/fortest/MtoMParameterBeanNoDataHandler.java
@@ -19,7 +19,7 @@
package org.apache.cxf.javascript.fortest;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import jakarta.xml.bind.annotation.XmlMimeType;
import jakarta.xml.bind.annotation.XmlType;
@@ -40,15 +40,11 @@ public class MtoMParameterBeanNoDataHandler {
}
@XmlMimeType("text/plain;charset=utf-8")
- public byte[] getNotXml10() throws UnsupportedEncodingException {
- return notXml10.getBytes("utf-8");
+ public byte[] getNotXml10() {
+ return notXml10.getBytes(StandardCharsets.UTF_8);
}
public void setNotXml10(byte[] notXml10) {
- try {
- this.notXml10 = new String(notXml10, "utf-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
+ this.notXml10 = new String(notXml10, StandardCharsets.UTF_8);
}
public void setNotXml10(String notXml10) {
this.notXml10 = notXml10;
diff --git
a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
index 1a68ae1d94b..58ae433d095 100644
---
a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
+++
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
@@ -161,6 +161,7 @@ public class ThreadLocalClientState implements ClientState {
}
}
+ @SuppressWarnings("PMD.OverridingThreadRun")
private class CleanupThread extends Thread {
private Thread thread;
private long originalTime;
diff --git
a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/aegis/AegisElementProviderTest.java
b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/aegis/AegisElementProviderTest.java
index eb86eff313c..5660c9f1953 100644
---
a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/aegis/AegisElementProviderTest.java
+++
b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/aegis/AegisElementProviderTest.java
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.InvalidPropertiesFormatException;
import java.util.Map;
@@ -78,7 +79,7 @@ public class AegisElementProviderTest {
@Test
public void testReadFrom() throws Exception {
MessageBodyReader<AegisTestBean> p = new AegisElementProvider<>();
- byte[] simpleBytes = simpleBeanXml.getBytes("utf-8");
+ byte[] simpleBytes = simpleBeanXml.getBytes(StandardCharsets.UTF_8);
AegisTestBean bean = p.readFrom(AegisTestBean.class, null, null,
null, null, new
ByteArrayInputStream(simpleBytes));
assertEquals("hovercraft", bean.getStrValue());
@@ -89,7 +90,7 @@ public class AegisElementProviderTest {
@Test
public void testNoNamespaceReadFrom() throws Exception {
MessageBodyReader<AegisTestBean> p = new
NoNamespaceAegisElementProvider<>();
- byte[] bytes = noNamespaceXml.getBytes("utf-8");
+ byte[] bytes = noNamespaceXml.getBytes(StandardCharsets.UTF_8);
AegisTestBean bean = p.readFrom(AegisTestBean.class, null, null,
null, null, new
ByteArrayInputStream(bytes));
assertEquals("hovercraft", bean.getStrValue());
@@ -107,7 +108,7 @@ public class AegisElementProviderTest {
MediaType.APPLICATION_OCTET_STREAM_TYPE,
new MetadataMap<String, Object>(), os);
byte[] bytes = os.toByteArray();
- String xml = new String(bytes, "utf-8");
+ String xml = new String(bytes, StandardCharsets.UTF_8);
assertEquals(simpleBeanXml, xml);
}
@@ -122,7 +123,7 @@ public class AegisElementProviderTest {
MediaType.APPLICATION_OCTET_STREAM_TYPE,
new MetadataMap<String, Object>(), os);
byte[] bytes = os.toByteArray();
- String xml = new String(bytes, "utf-8");
+ String xml = new String(bytes, StandardCharsets.UTF_8);
assertEquals(noNamespaceXml, xml);
}
@@ -151,10 +152,10 @@ public class AegisElementProviderTest {
MediaType.APPLICATION_OCTET_STREAM_TYPE,
new MetadataMap<String, Object>(), os);
byte[] bytes = os.toByteArray();
- String xml = new String(bytes, "utf-8");
+ String xml = new String(bytes, StandardCharsets.UTF_8);
MessageBodyReader<Map<AegisTestBean, AegisSuperBean>> reader
= new AegisElementProvider<>();
- byte[] simpleBytes = xml.getBytes("utf-8");
+ byte[] simpleBytes = xml.getBytes(StandardCharsets.UTF_8);
Map<AegisTestBean, AegisSuperBean> map2 = reader.readFrom(null,
mapType, new Annotation[]{},
MediaType.APPLICATION_OCTET_STREAM_TYPE,
diff --git
a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
index 9b0c928f29e..9c87c8475dd 100644
---
a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
+++
b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
@@ -389,6 +389,7 @@ public class AsyncHTTPConduitFactory implements
HTTPConduitFactory {
return client;
}
+ @SuppressWarnings("PMD.OverridingThreadRun")
public class CloseIdleConnectionThread extends Thread {
private final PoolingNHttpClientConnectionManager connMgr;
diff --git
a/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/AsyncHTTPConduitFactory.java
b/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/AsyncHTTPConduitFactory.java
index 75deb097ac6..bf1a7c8a787 100644
---
a/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/AsyncHTTPConduitFactory.java
+++
b/rt/transports/http-hc5/src/main/java/org/apache/cxf/transport/http/asyncclient/hc5/AsyncHTTPConduitFactory.java
@@ -420,6 +420,7 @@ public class AsyncHTTPConduitFactory implements
HTTPConduitFactory {
return maxConnections;
}
+ @SuppressWarnings("PMD.OverridingThreadRun")
public class CloseIdleConnectionThread extends Thread {
private final PoolingAsyncClientConnectionManager connMgr;
private final CloseableHttpAsyncClient client;
diff --git
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java
index 1a994f76154..6e77dcde1e7 100644
---
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java
+++
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/DestinationRegistryImpl.java
@@ -18,8 +18,8 @@
*/
package org.apache.cxf.transport.http;
-import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -52,25 +52,17 @@ public class DestinationRegistryImpl implements
DestinationRegistry, ServletConf
if (dest != null && dest != destination) {
throw new RuntimeException("Already a destination on " + path);
}
- try {
- String path2 = URLDecoder.decode(path, "UTF-8");
- if (!path.equals(path2)) {
- decodedDestinations.put(path2, destination);
- }
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException("Unsupported Encoding", e);
+ String path2 = URLDecoder.decode(path, StandardCharsets.UTF_8);
+ if (!path.equals(path2)) {
+ decodedDestinations.put(path2, destination);
}
}
public synchronized void removeDestination(String path) {
destinations.remove(path);
- try {
- String path2 = URLDecoder.decode(path, "UTF-8");
- if (!path.equals(path2)) {
- decodedDestinations.remove(path2);
- }
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException("Unsupported Encoding", e);
+ String path2 = URLDecoder.decode(path, StandardCharsets.UTF_8);
+ if (!path.equals(path2)) {
+ decodedDestinations.remove(path2);
}
}
diff --git
a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketUtils.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketUtils.java
index ef7459362a6..53f2c1e0f3a 100644
---
a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketUtils.java
+++
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketUtils.java
@@ -22,6 +22,7 @@ package org.apache.cxf.transport.websocket;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
@@ -250,7 +251,7 @@ public final class WebSocketUtils {
public ByteArrayBuilder append(String s) {
try {
- baos.write(s.getBytes("utf-8"));
+ baos.write(s.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
// ignore
}
diff --git
a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty12/Jetty12WebSocketDestination.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty12/Jetty12WebSocketDestination.java
index 12fedaffb8e..910adbc3db4 100644
---
a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty12/Jetty12WebSocketDestination.java
+++
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/jetty12/Jetty12WebSocketDestination.java
@@ -21,10 +21,10 @@ package org.apache.cxf.transport.websocket.jetty12;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.net.URL;
import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
import java.security.Principal;
import java.util.Enumeration;
import java.util.Locale;
@@ -353,12 +353,8 @@ public class Jetty12WebSocketDestination extends
JettyHTTPDestination implements
@org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage
public void onMessage(String message) {
- try {
- byte[] bdata = message.getBytes("utf-8");
- onBinaryMessage(ByteBuffer.wrap(bdata), null);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
+ byte[] bdata = message.getBytes(StandardCharsets.UTF_8);
+ onBinaryMessage(ByteBuffer.wrap(bdata), null);
}
@org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage
diff --git
a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ClassReader.java
b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ClassReader.java
index 7c0066429eb..3798ee17f63 100644
--- a/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ClassReader.java
+++ b/rt/wsdl/src/main/java/org/apache/cxf/wsdl/service/factory/ClassReader.java
@@ -29,6 +29,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@@ -299,8 +300,8 @@ class ClassReader extends ByteArrayInputStream {
pos = cpoolIndex[i];
int len = readShort();
skipFully(len);
- cpool[i] = new String(buf, pos - len, len, "utf-8");
- s = new String(buf, pos - len, len, "utf-8");
+ cpool[i] = new String(buf, pos - len, len,
StandardCharsets.UTF_8);
+ s = new String(buf, pos - len, len, StandardCharsets.UTF_8);
}
return s;
} finally {
diff --git
a/rt/wsdl/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java
b/rt/wsdl/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java
index 0a033d394ee..4c09197fe89 100644
--- a/rt/wsdl/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java
+++ b/rt/wsdl/src/test/java/org/apache/cxf/wsdl11/WSDLServiceBuilderTest.java
@@ -25,6 +25,7 @@ import java.net.URI;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.List;
import java.util.logging.Logger;
@@ -473,10 +474,10 @@ public class WSDLServiceBuilderTest {
}
String filePath =
this.getClass().getResource("./s1/s2/s4/schema4.xsd").toURI().getPath();
String importPath =
schemaImport.getAttributeNode("schemaLocation").getValue();
- if (!new URI(URLEncoder.encode(importPath, "utf-8")).isAbsolute()) {
+ if (!new URI(URLEncoder.encode(importPath,
StandardCharsets.UTF_8)).isAbsolute()) {
schemaImport.getAttributeNode("schemaLocation").setNodeValue("file:" +
filePath);
String fileStr =
this.getClass().getResource("./s1/s2/schema2.xsd").toURI().getPath();
- fileStr = URLDecoder.decode(fileStr, "utf-8");
+ fileStr = URLDecoder.decode(fileStr, StandardCharsets.UTF_8);
File file = new File(fileStr);
if (file.exists()) {
file.delete();
diff --git
a/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsSubscription.java
b/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsSubscription.java
index 693d453daf8..d2a5d774c27 100644
---
a/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsSubscription.java
+++
b/services/wsn/wsn-core/src/main/java/org/apache/cxf/wsn/jms/JmsSubscription.java
@@ -266,6 +266,7 @@ public abstract class JmsSubscription extends
AbstractSubscription implements Me
protected abstract void doNotify(Notify notify);
+ @SuppressWarnings("PMD.OverridingThreadRun")
class TerminationThread extends Thread {
public void run() {
while (checkTermination) {
diff --git
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServerAsyncClient.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServerAsyncClient.java
index 540c8f35ca1..7032d378518 100644
---
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServerAsyncClient.java
+++
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServerAsyncClient.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.Produces;
@@ -91,7 +92,7 @@ public class BookServerAsyncClient extends
AbstractServerTestServerBase {
public void writeTo(Boolean t, Class<?> type, Type genericType,
Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String,
Object> httpHeaders,
OutputStream os) throws IOException,
WebApplicationException {
- byte[] bytes = t.toString().getBytes("UTF-8");
+ byte[] bytes = t.toString().getBytes(StandardCharsets.UTF_8);
os.write(bytes);
}
diff --git
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
index 9a2e530385c..d78ac0910f9 100644
---
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
+++
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
@@ -24,6 +24,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -269,8 +270,8 @@ public class BookStoreSpring {
public Book getBookISO() throws Exception {
String eWithAcute = "\u00E9";
String helloStringUTF16 = "F" + eWithAcute + "lix";
- byte[] iso88591bytes = helloStringUTF16.getBytes("ISO-8859-1");
- String helloStringISO88591 = new String(iso88591bytes, "ISO-8859-1");
+ byte[] iso88591bytes =
helloStringUTF16.getBytes(StandardCharsets.ISO_8859_1);
+ String helloStringISO88591 = new String(iso88591bytes,
StandardCharsets.ISO_8859_1);
return new Book(helloStringISO88591, 333L);
}
diff --git
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
index ff61f02e3f5..7e39104700a 100644
---
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
+++
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
@@ -348,7 +348,7 @@ public class JAXRSClientServerSpringBookTest extends
AbstractBusClientServerTest
WebClient wc = WebClient.create(address);
wc.accept("application/json" + (charset == null ? "" :
";charset=ISO-8859-1"));
byte[] iso88591bytes = wc.get(byte[].class);
- String helloStringISO88591 = new String(iso88591bytes, "ISO-8859-1");
+ String helloStringISO88591 = new String(iso88591bytes,
StandardCharsets.ISO_8859_1);
String name = helloStringISO88591.substring(
helloStringISO88591.indexOf("\"name\":\"") +
"\"name\":\"".length(),
@@ -362,7 +362,7 @@ public class JAXRSClientServerSpringBookTest extends
AbstractBusClientServerTest
WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000L);
wc.accept("application/xml" + (charset == null ? "" :
";charset=ISO-8859-1"));
byte[] iso88591bytes = wc.get(byte[].class);
- String helloStringISO88591 = new String(iso88591bytes, "ISO-8859-1");
+ String helloStringISO88591 = new String(iso88591bytes,
StandardCharsets.ISO_8859_1);
String name = helloStringISO88591.substring(
helloStringISO88591.indexOf("<name>") + "<name>".length(),
@@ -374,7 +374,7 @@ public class JAXRSClientServerSpringBookTest extends
AbstractBusClientServerTest
private void compareNames(String name) throws Exception {
String eWithAcute = "\u00E9";
String nameUTF16 = "F" + eWithAcute + "lix";
- String nameExpected = new String(nameUTF16.getBytes("ISO-8859-1"),
"ISO-8859-1");
+ String nameExpected = new
String(nameUTF16.getBytes(StandardCharsets.ISO_8859_1),
StandardCharsets.ISO_8859_1);
assertEquals(nameExpected, name);
}
diff --git
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/AbstractCompletableFutureServer.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/AbstractCompletableFutureServer.java
index 93f801740ea..24a7b4f0d56 100644
---
a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/AbstractCompletableFutureServer.java
+++
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/AbstractCompletableFutureServer.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.Produces;
@@ -88,7 +89,7 @@ public abstract class AbstractCompletableFutureServer extends
AbstractServerTest
public void writeTo(Boolean t, Class<?> type, Type genericType,
Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String,
Object> httpHeaders,
OutputStream os) throws IOException,
WebApplicationException {
- byte[] bytes = t.toString().getBytes("UTF-8");
+ byte[] bytes = t.toString().getBytes(StandardCharsets.UTF_8);
os.write(bytes);
}
diff --git
a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JAXWSServer.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JAXWSServer.java
index 702e33085f4..814bc077026 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JAXWSServer.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/JAXWSServer.java
@@ -136,19 +136,17 @@ public class JAXWSServer extends
AbstractBusTestServerBase {
public Future<?> greetMeAsync(final String requestType,
final AsyncHandler<GreetMeResponse>
asyncHandler) {
final ServerAsyncResponse<GreetMeResponse> r = new
ServerAsyncResponse<>();
- new Thread() {
- public void run() {
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- //ignore
- }
- GreetMeResponse resp = new GreetMeResponse();
- resp.setResponseType("Hello " + requestType);
- r.set(resp);
- asyncHandler.handleResponse(r);
+ new Thread(() -> {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ //ignore
}
- } .start();
+ GreetMeResponse resp = new GreetMeResponse();
+ resp.setResponseType("Hello " + requestType);
+ r.set(resp);
+ asyncHandler.handleResponse(r);
+ }).start();
return r;
}
}
@@ -165,17 +163,15 @@ public class JAXWSServer extends
AbstractBusTestServerBase {
public Future<?> invokeAsync(final StreamSource s, final
AsyncHandler<Source> asyncHandler) {
final ServerAsyncResponse<Source> r = new ServerAsyncResponse<>();
- new Thread() {
- public void run() {
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- // ignore
- }
- r.set(s);
- asyncHandler.handleResponse(r);
+ new Thread(() -> {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // ignore
}
- } .start();
+ r.set(s);
+ asyncHandler.handleResponse(r);
+ }).start();
return r;
}
}
diff --git
a/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
b/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
index 4708de7e91d..39f138af4e2 100644
---
a/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
+++
b/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
@@ -73,26 +73,24 @@ public class BookStore extends BookStoreClientCloseable {
public void forBook(@Context SseEventSink sink, @PathParam("id") final
String id,
@HeaderParam(HttpHeaders.LAST_EVENT_ID_HEADER) @DefaultValue("0")
final String lastEventId) {
- new Thread() {
- public void run() {
- try {
- final Integer id = Integer.valueOf(lastEventId);
- final OutboundSseEvent.Builder builder =
sse.newEventBuilder();
-
- sink.send(createEvent(builder.name("book"), id + 1));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 2));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 3));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 4));
- Thread.sleep(200);
- sink.close();
- } catch (final InterruptedException ex) {
- LOG.error("Communication error", ex);
- }
+ new Thread(() -> {
+ try {
+ final Integer lastId = Integer.valueOf(lastEventId);
+ final OutboundSseEvent.Builder builder = sse.newEventBuilder();
+
+ sink.send(createEvent(builder.name("book"), lastId + 1));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 2));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 3));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 4));
+ Thread.sleep(200);
+ sink.close();
+ } catch (final InterruptedException ex) {
+ LOG.error("Communication error", ex);
}
- }.start();
+ }).start();
}
@POST
@@ -101,26 +99,24 @@ public class BookStore extends BookStoreClientCloseable {
@Consumes(MediaType.TEXT_PLAIN)
public void forBookPOST(@Context SseEventSink sink, @PathParam("id") final
String id,
final String lastEventId) {
- new Thread() {
- public void run() {
- try {
- final Integer id = Integer.valueOf(lastEventId);
- final OutboundSseEvent.Builder builder =
sse.newEventBuilder();
-
- sink.send(createEvent(builder.name("book"), id + 1));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 2));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 3));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 4));
- Thread.sleep(200);
- sink.close();
- } catch (final InterruptedException ex) {
- LOG.error("Communication error", ex);
- }
+ new Thread(() -> {
+ try {
+ final Integer lastId = Integer.valueOf(lastEventId);
+ final OutboundSseEvent.Builder builder = sse.newEventBuilder();
+
+ sink.send(createEvent(builder.name("book"), lastId + 1));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 2));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 3));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 4));
+ Thread.sleep(200);
+ sink.close();
+ } catch (final InterruptedException ex) {
+ LOG.error("Communication error", ex);
}
- }.start();
+ }).start();
}
@GET
@@ -201,32 +197,28 @@ public class BookStore extends BookStoreClientCloseable {
@Path("/filtered/sse")
@Produces(MediaType.SERVER_SENT_EVENTS)
public void filtered(@Context SseEventSink sink) {
- new Thread() {
- public void run() {
- try {
- Thread.sleep(200);
- sink.close();
- } catch (final InterruptedException ex) {
- LOG.error("Communication error", ex);
- }
+ new Thread(() -> {
+ try {
+ Thread.sleep(200);
+ sink.close();
+ } catch (final InterruptedException ex) {
+ LOG.error("Communication error", ex);
}
- }.start();
+ }).start();
}
@GET
@Path("/headers/sse")
@Produces(MediaType.SERVER_SENT_EVENTS)
public void headers(@Context SseEventSink sink) {
- new Thread() {
- public void run() {
- try {
- Thread.sleep(200);
- sink.close();
- } catch (final InterruptedException ex) {
- LOG.error("Communication error", ex);
- }
+ new Thread(() -> {
+ try {
+ Thread.sleep(200);
+ sink.close();
+ } catch (final InterruptedException ex) {
+ LOG.error("Communication error", ex);
}
- }.start();
+ }).start();
}
@GET
diff --git
a/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore2.java
b/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore2.java
index aad2bedf3ac..a79831ff7f2 100644
---
a/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore2.java
+++
b/systests/rs-sse/rs-sse-base/src/main/java/org/apache/cxf/systest/jaxrs/sse/BookStore2.java
@@ -72,26 +72,24 @@ public class BookStore2 extends BookStoreClientCloseable {
public void forBook(@Context SseEventSink sink, @PathParam("id") final
String id,
@HeaderParam(HttpHeaders.LAST_EVENT_ID_HEADER) @DefaultValue("0")
final String lastEventId) {
- new Thread() {
- public void run() {
- try {
- final Integer id = Integer.valueOf(lastEventId);
- final OutboundSseEvent.Builder builder =
sse.newEventBuilder();
-
- sink.send(createEvent(builder.name("book"), id + 1));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 2));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 3));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 4));
- Thread.sleep(200);
- sink.close();
- } catch (final InterruptedException ex) {
- LOG.error("Communication error", ex);
- }
+ new Thread(() -> {
+ try {
+ final Integer lastId = Integer.valueOf(lastEventId);
+ final OutboundSseEvent.Builder builder = sse.newEventBuilder();
+
+ sink.send(createEvent(builder.name("book"), lastId + 1));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 2));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 3));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 4));
+ Thread.sleep(200);
+ sink.close();
+ } catch (final InterruptedException ex) {
+ LOG.error("Communication error", ex);
}
- }.start();
+ }).start();
}
@POST
@@ -100,26 +98,24 @@ public class BookStore2 extends BookStoreClientCloseable {
@Consumes(MediaType.TEXT_PLAIN)
public void forBookPOST(@Context SseEventSink sink, @PathParam("id") final
String id,
final String lastEventId) {
- new Thread() {
- public void run() {
- try {
- final Integer id = Integer.valueOf(lastEventId);
- final OutboundSseEvent.Builder builder =
sse.newEventBuilder();
-
- sink.send(createEvent(builder.name("book"), id + 1));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 2));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 3));
- Thread.sleep(200);
- sink.send(createEvent(builder.name("book"), id + 4));
- Thread.sleep(200);
- sink.close();
- } catch (final InterruptedException ex) {
- LOG.error("Communication error", ex);
- }
+ new Thread(() -> {
+ try {
+ final Integer lastId = Integer.valueOf(lastEventId);
+ final OutboundSseEvent.Builder builder = sse.newEventBuilder();
+
+ sink.send(createEvent(builder.name("book"), lastId + 1));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 2));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 3));
+ Thread.sleep(200);
+ sink.send(createEvent(builder.name("book"), lastId + 4));
+ Thread.sleep(200);
+ sink.close();
+ } catch (final InterruptedException ex) {
+ LOG.error("Communication error", ex);
}
- }.start();
+ }).start();
}
@GET
@@ -200,16 +196,14 @@ public class BookStore2 extends BookStoreClientCloseable {
@Path("/filtered/sse")
@Produces(MediaType.SERVER_SENT_EVENTS)
public void filtered(@Context SseEventSink sink) {
- new Thread() {
- public void run() {
- try {
- Thread.sleep(200);
- sink.close();
- } catch (final InterruptedException ex) {
- LOG.error("Communication error", ex);
- }
+ new Thread(() -> {
+ try {
+ Thread.sleep(200);
+ sink.close();
+ } catch (final InterruptedException ex) {
+ LOG.error("Communication error", ex);
}
- }.start();
+ }).start();
}
@GET
@@ -226,9 +220,6 @@ public class BookStore2 extends BookStoreClientCloseable {
throw new RuntimeException("CXF-9189-MARKER: exception from SSE
resource method should be logged");
}
-
-
-
@PUT
@Path("/filtered/stats")
public void clearStats() {
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringClientOnlyJaxrsTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringClientOnlyJaxrsTest.java
index d901468e52a..7bb4dba80fe 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringClientOnlyJaxrsTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringClientOnlyJaxrsTest.java
@@ -59,7 +59,7 @@ import static org.assertj.core.api.Assertions.entry;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes =
SpringClientOnlyJaxrsTest.TestConfig.class)
@ActiveProfiles("client")
-public class SpringClientOnlyJaxrsTest {
+class SpringClientOnlyJaxrsTest {
@Autowired
private MeterRegistry registry;
@@ -111,7 +111,7 @@ public class SpringClientOnlyJaxrsTest {
}
@Test
- public void testJaxrsClientSuccessMetric() {
+ void testJaxrsClientSuccessMetric() {
final WebTarget target = createWebTarget();
final Builder builder =
target.request().header(HttpHeaders.CONTENT_TYPE, "text/plain");
@@ -139,7 +139,7 @@ public class SpringClientOnlyJaxrsTest {
}
@Test
- public void testJaxrsClientExceptionMetric() {
+ void testJaxrsClientExceptionMetric() {
final WebTarget target = ClientBuilder
.newClient()
.register(new MetricsFeature(metricsProvider))
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java
index d4cb22a7700..5b4f5a9b8e6 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsApplicationTest.java
@@ -68,7 +68,7 @@ import static org.hamcrest.Matchers.empty;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes =
SpringJaxrsApplicationTest.TestConfig.class)
@ActiveProfiles("jaxrs")
-public class SpringJaxrsApplicationTest {
+class SpringJaxrsApplicationTest {
@Autowired
private MeterRegistry registry;
@@ -104,7 +104,7 @@ public class SpringJaxrsApplicationTest {
}
@Test
- public void testJaxrsSuccessMetric() {
+ void testJaxrsSuccessMetric() {
final WebTarget target = createWebTarget();
try (Response r = target.request().get()) {
@@ -145,7 +145,7 @@ public class SpringJaxrsApplicationTest {
}
@Test
- public void testJaxrsSubresourceSuccessMetric() {
+ void testJaxrsSubresourceSuccessMetric() {
final WebTarget target = createWebTarget().path("catalog").path("cxf");
try (Response r = target.request().get()) {
@@ -186,7 +186,7 @@ public class SpringJaxrsApplicationTest {
}
@Test
- public void testJaxrsFailedMetric() {
+ void testJaxrsFailedMetric() {
final WebTarget target = createWebTarget();
assertThatThrownBy(() -> target.path("100").request().get(Book.class))
@@ -227,7 +227,7 @@ public class SpringJaxrsApplicationTest {
}
@Test
- public void testJaxrsExceptionMetric() {
+ void testJaxrsExceptionMetric() {
final WebTarget target = createWebTarget();
assertThatThrownBy(() -> target.request().delete(String.class))
@@ -268,7 +268,7 @@ public class SpringJaxrsApplicationTest {
}
@Test
- public void testJaxrsClientExceptionMetric() {
+ void testJaxrsClientExceptionMetric() {
final int fakePort =
Integer.parseInt(TestUtil.getPortNumber("client-exception"));
final WebTarget target = ClientBuilder
@@ -300,7 +300,7 @@ public class SpringJaxrsApplicationTest {
}
@Test
- public void testJaxrsProxySuccessMetric() {
+ void testJaxrsProxySuccessMetric() {
final LibraryApi api = createApi(port);
try (Response r = api.getBooks(1)) {
@@ -341,7 +341,7 @@ public class SpringJaxrsApplicationTest {
}
@Test
- public void testJaxrsProxyExceptionMetric() {
+ void testJaxrsProxyExceptionMetric() {
final LibraryApi api = createApi(port);
assertThatThrownBy(() -> api.deleteBooks())
@@ -382,7 +382,7 @@ public class SpringJaxrsApplicationTest {
}
@Test
- public void testJaxrsProxyFailedMetric() {
+ void testJaxrsProxyFailedMetric() {
final LibraryApi api = createApi(port);
try (Response r = api.getBook("100")) {
@@ -423,7 +423,7 @@ public class SpringJaxrsApplicationTest {
}
@Test
- public void testJaxrsProxyClientExceptionMetric() {
+ void testJaxrsProxyClientExceptionMetric() {
final int fakePort =
Integer.parseInt(TestUtil.getPortNumber("proxy-client-exception"));
final LibraryApi api = createApi(fakePort);
@@ -451,7 +451,7 @@ public class SpringJaxrsApplicationTest {
}
@Test
- public void testJaxrsProxySubresourceSuccessMetric() {
+ void testJaxrsProxySubresourceSuccessMetric() {
final LibraryApi api = createApi(port);
final Collection<Book> books = api.catalog().getCatalog("cxf");
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsClassesScanningTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsClassesScanningTest.java
index 4f75a840489..68bab527e29 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsClassesScanningTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsClassesScanningTest.java
@@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
classes = SpringJaxrsClassesScanningTest.TestConfig.class)
@ActiveProfiles("jaxrs-classes-scan")
-public class SpringJaxrsClassesScanningTest {
+class SpringJaxrsClassesScanningTest {
@Autowired
private AbstractJaxrsClassesScanServer scanner;
@@ -42,7 +42,7 @@ public class SpringJaxrsClassesScanningTest {
}
@Test
- public void testCxfClassesScan() {
+ void testCxfClassesScan() {
// No features are registered since class scanner only looks for
JAX-RS's
// @Provider annotations, not JAX-RS/CXF Features.
assertThat(scanner.getFeatures()).isEmpty();
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsComponentScanningTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsComponentScanningTest.java
index de2523e9e0b..10d61973a04 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsComponentScanningTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsComponentScanningTest.java
@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
classes = SpringJaxrsComponentScanningTest.TestConfig.class)
@ActiveProfiles("jaxrs-component-scan")
-public class SpringJaxrsComponentScanningTest {
+class SpringJaxrsComponentScanningTest {
@Autowired
private AbstractSpringComponentScanServer scanner;
@@ -47,7 +47,7 @@ public class SpringJaxrsComponentScanningTest {
}
@Test
- public void testCxfComponentScan() {
+ void testCxfComponentScan() {
// The component scanner only looks for CXF's @Provider annotations,
// not JAX-RS Features/@Provider.
assertThat(scanner.getFeatures())
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabilityTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabilityTest.java
index de3b42e4e5d..e646e510cc2 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabilityTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsObservabilityTest.java
@@ -62,7 +62,7 @@ import static org.hamcrest.Matchers.hasSize;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes =
SpringJaxrsObservabilityTest.TestConfig.class)
@ActiveProfiles("jaxrs")
@AutoConfigureObservability
-public class SpringJaxrsObservabilityTest {
+class SpringJaxrsObservabilityTest {
@Autowired
private MeterRegistry registry;
@@ -118,7 +118,7 @@ public class SpringJaxrsObservabilityTest {
}
@Test
- public void testJaxrsSuccessMetric() {
+ void testJaxrsSuccessMetric() {
final WebTarget target = createWebTarget();
try (Response r = target.request().get()) {
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java
index 5feef3ac73b..0756146f75f 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsTest.java
@@ -70,7 +70,7 @@ import static org.hamcrest.Matchers.empty;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes =
SpringJaxrsTest.TestConfig.class)
@ActiveProfiles("jaxrs")
-public class SpringJaxrsTest {
+class SpringJaxrsTest {
@Autowired
private MeterRegistry registry;
@@ -114,7 +114,7 @@ public class SpringJaxrsTest {
}
@Test
- public void testJaxrsSuccessMetric() {
+ void testJaxrsSuccessMetric() {
final WebTarget target = createWebTarget();
try (Response r = target.request().get()) {
@@ -155,7 +155,7 @@ public class SpringJaxrsTest {
}
@Test
- public void testJaxrsFailedMetric() {
+ void testJaxrsFailedMetric() {
final WebTarget target = createWebTarget();
assertThatThrownBy(() -> target.path("100").request().get(Book.class))
@@ -196,7 +196,7 @@ public class SpringJaxrsTest {
}
@Test
- public void testJaxrsExceptionMetric() {
+ void testJaxrsExceptionMetric() {
final WebTarget target = createWebTarget();
assertThatThrownBy(() -> target.request().delete(String.class))
@@ -237,7 +237,7 @@ public class SpringJaxrsTest {
}
@Test
- public void testJaxrsClientExceptionMetric() {
+ void testJaxrsClientExceptionMetric() {
final int fakePort =
Integer.parseInt(TestUtil.getPortNumber("client-exception"));
final WebTarget target = ClientBuilder
@@ -269,7 +269,7 @@ public class SpringJaxrsTest {
}
@Test
- public void testJaxrsProxySuccessMetric() {
+ void testJaxrsProxySuccessMetric() {
final LibraryApi api = createApi(port);
try (Response r = api.getBooks(1)) {
@@ -310,7 +310,7 @@ public class SpringJaxrsTest {
}
@Test
- public void testJaxrsProxyExceptionMetric() {
+ void testJaxrsProxyExceptionMetric() {
final LibraryApi api = createApi(port);
assertThatThrownBy(() -> api.deleteBooks())
@@ -351,7 +351,7 @@ public class SpringJaxrsTest {
}
@Test
- public void testJaxrsProxyFailedMetric() {
+ void testJaxrsProxyFailedMetric() {
final LibraryApi api = createApi(port);
try (Response r = api.getBook("100")) {
@@ -392,7 +392,7 @@ public class SpringJaxrsTest {
}
@Test
- public void testJaxrsProxyClientExceptionMetric() {
+ void testJaxrsProxyClientExceptionMetric() {
final int fakePort =
Integer.parseInt(TestUtil.getPortNumber("proxy-client-exception"));
final LibraryApi api = createApi(fakePort);
@@ -420,7 +420,7 @@ public class SpringJaxrsTest {
}
@Test
- public void testJaxrsCustomHttpMethodMetric() {
+ void testJaxrsCustomHttpMethodMetric() {
final WebTarget target = createWebTarget();
try (Response r = target.request().trace()) {
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsWebObservabilityTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsWebObservabilityTest.java
index a553f6a6838..c7a0ad60d35 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsWebObservabilityTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringJaxrsWebObservabilityTest.java
@@ -61,7 +61,7 @@ import static org.hamcrest.Matchers.hasSize;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes =
SpringJaxrsWebObservabilityTest.TestConfig.class)
@ActiveProfiles("jaxrs")
@AutoConfigureObservability
-public class SpringJaxrsWebObservabilityTest {
+class SpringJaxrsWebObservabilityTest {
@Autowired
private MeterRegistry registry;
@@ -117,7 +117,7 @@ public class SpringJaxrsWebObservabilityTest {
}
@Test
- public void testJaxrsSuccessMetric() {
+ void testJaxrsSuccessMetric() {
final WebTarget target = createWebTarget();
try (Response r = target.request().get()) {
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringSseEmitterTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringSseEmitterTest.java
index 721b3b285cb..0d413441a6f 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringSseEmitterTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxrs/spring/boot/SpringSseEmitterTest.java
@@ -47,7 +47,7 @@ import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, classes =
SpringSseEmitterTest.LibraryController.class)
-public class SpringSseEmitterTest {
+class SpringSseEmitterTest {
private static final int CNT = 5;
@LocalServerPort
private int port;
@@ -78,7 +78,7 @@ public class SpringSseEmitterTest {
}
@Test
- public void testSseEvents() throws InterruptedException {
+ void testSseEvents() throws InterruptedException {
final WebTarget target = createWebTarget();
final Collection<Book> books = new ArrayList<>(CNT);
final AtomicReference<Throwable> throwable = new AtomicReference<>();
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsInjectionTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsInjectionTest.java
index a2ab168c338..17f2ff017ab 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsInjectionTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsInjectionTest.java
@@ -53,7 +53,7 @@ import static org.assertj.core.api.Assertions.assertThat;
webEnvironment = WebEnvironment.RANDOM_PORT,
classes = SpringJaxwsInjectionTest.TestConfig.class)
@ActiveProfiles("jaxws")
-public class SpringJaxwsInjectionTest {
+class SpringJaxwsInjectionTest {
private static final String DUMMY_REQUEST_BODY = "<q0:sayHello
xmlns:q0=\"http://service.ws.sample/\">"
+ "<name>Elan</name>"
@@ -82,7 +82,7 @@ public class SpringJaxwsInjectionTest {
}
@Test
- public void testJaxwsWebServiceContext() throws MalformedURLException {
+ void testJaxwsWebServiceContext() throws MalformedURLException {
// given in setUp
// when
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsObservabilityTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsObservabilityTest.java
index 5858a823691..b46baffdee4 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsObservabilityTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsObservabilityTest.java
@@ -72,7 +72,7 @@ import static org.hamcrest.Matchers.hasSize;
)
@ActiveProfiles("jaxws")
@AutoConfigureObservability
-public class SpringJaxwsObservabilityTest {
+class SpringJaxwsObservabilityTest {
private static final String DUMMY_REQUEST_BODY = "<q0:sayHello
xmlns:q0=\"http://service.ws.sample/\">"
+ "<name>Elan</name>"
@@ -150,7 +150,7 @@ public class SpringJaxwsObservabilityTest {
}
@Test
- public void testJaxwsObservation() throws MalformedURLException {
+ void testJaxwsObservation() throws MalformedURLException {
// given in setUp
// when
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java
index eedfb70c2e1..9000697c28d 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTest.java
@@ -90,8 +90,7 @@ import static org.hamcrest.Matchers.empty;
})
@ImportResource("classpath:spring/jaxws-client.xml")
@ActiveProfiles("jaxws")
-
-public class SpringJaxwsTest {
+class SpringJaxwsTest {
private static final String DUMMY_REQUEST_BODY = "<q0:sayHello
xmlns:q0=\"http://service.ws.sample/\">"
+ "<name>Elan</name>"
@@ -154,7 +153,7 @@ public class SpringJaxwsTest {
}
@Test
- public void testJaxwsSuccessMetric() throws MalformedURLException {
+ void testJaxwsSuccessMetric() throws MalformedURLException {
// given in setUp
// when
@@ -202,7 +201,7 @@ public class SpringJaxwsTest {
}
@Test
- public void testJaxwsFailedMetric() {
+ void testJaxwsFailedMetric() {
// given
String requestBody = "<q0:sayHello
xmlns:q0=\"http://service.ws.sample/\"></q0:sayHello>";
@@ -252,7 +251,7 @@ public class SpringJaxwsTest {
@Test
@ExtendWith(OutputCaptureExtension.class)
- public void testAfterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput
output) throws MalformedURLException {
+ void testAfterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output)
throws MalformedURLException {
// given in setUp
// when
@@ -267,7 +266,7 @@ public class SpringJaxwsTest {
@Test
@ExtendWith(OutputCaptureExtension.class)
- public void testDoesNotDenyNorLogIfMaxUrisIsNotReached(CapturedOutput
output) throws MalformedURLException {
+ void testDoesNotDenyNorLogIfMaxUrisIsNotReached(CapturedOutput output)
throws MalformedURLException {
// given in setUp
// when
@@ -279,7 +278,7 @@ public class SpringJaxwsTest {
}
@Test
- public void testJaxwsProxySuccessMetric() throws MalformedURLException {
+ void testJaxwsProxySuccessMetric() throws MalformedURLException {
final HelloService api = createApi(port, HELLO_SERVICE_NAME_V1);
assertThat(api.sayHello("Elan")).isEqualTo("Hello, Elan");
@@ -319,7 +318,7 @@ public class SpringJaxwsTest {
}
@Test
- public void testJaxwsFromXmlProxy() throws MalformedURLException {
+ void testJaxwsFromXmlProxy() throws MalformedURLException {
final HelloService api = createApiFromSpringXml();
//ensure the property placeholder is resolved
assertThat("http://localhost:port/Service/HelloV1")
@@ -329,7 +328,7 @@ public class SpringJaxwsTest {
}
@Test
- public void testJaxwsProxyFailedMetric() {
+ void testJaxwsProxyFailedMetric() {
final HelloService api = createApi(port, HELLO_SERVICE_NAME_V1);
// then
@@ -373,7 +372,7 @@ public class SpringJaxwsTest {
}
@Test
- public void testJaxwsProxyClientExceptionMetric() throws
MalformedURLException {
+ void testJaxwsProxyClientExceptionMetric() throws MalformedURLException {
final int fakePort =
Integer.parseInt(TestUtil.getPortNumber("proxy-client-exception"));
final HelloService api = createApi(fakePort, HELLO_SERVICE_NAME_V1);
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTimedTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTimedTest.java
index 215540abaa5..5c5a96bacc5 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTimedTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/jaxws/spring/boot/SpringJaxwsTimedTest.java
@@ -77,8 +77,7 @@ import static org.hamcrest.Matchers.empty;
})
@ImportResource("classpath:spring/jaxws-client.xml")
@ActiveProfiles("jaxws")
-
-public class SpringJaxwsTimedTest {
+class SpringJaxwsTimedTest {
private static final String DUMMY_REQUEST_BODY = "<q0:sayHello
xmlns:q0=\"http://service.ws.sample/\">"
+ "<name>Elan</name>"
@@ -131,7 +130,7 @@ public class SpringJaxwsTimedTest {
}
@Test
- public void testJaxwsTimedSuccessMetric() throws MalformedURLException {
+ void testJaxwsTimedSuccessMetric() throws MalformedURLException {
// given in setUp
// when
@@ -194,7 +193,7 @@ public class SpringJaxwsTimedTest {
}
@Test
- public void testJaxwsEmptyTimedSuccessMetric() throws
MalformedURLException {
+ void testJaxwsEmptyTimedSuccessMetric() throws MalformedURLException {
// given in setUp
// when
diff --git
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/spring/boot/ssl/SpringClientSslBundleTest.java
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/spring/boot/ssl/SpringClientSslBundleTest.java
index 8cbc28c4dac..ca62b474504 100644
---
a/systests/spring-boot/src/test/java/org/apache/cxf/systest/spring/boot/ssl/SpringClientSslBundleTest.java
+++
b/systests/spring-boot/src/test/java/org/apache/cxf/systest/spring/boot/ssl/SpringClientSslBundleTest.java
@@ -62,10 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@SpringBootTest(classes = SpringClientSslBundleTest.TestCfg.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("ssl")
-
-
-
-public class SpringClientSslBundleTest {
+class SpringClientSslBundleTest {
interface HelloApi {
@GET
@@ -141,8 +138,6 @@ public class SpringClientSslBundleTest {
SSLContext ctx = clientBundle.createSslContext();
assertThat(ctx).isNotNull();
-
-
String resp = api.hello();
assertThat(resp).isEqualTo("hello");
}
diff --git
a/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/jaxrs/BookServerAsyncClient.java
b/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/jaxrs/BookServerAsyncClient.java
index 481e9dbe178..8257e11878f 100644
---
a/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/jaxrs/BookServerAsyncClient.java
+++
b/systests/transport-hc5/src/test/java/org/apache/cxf/systest/hc5/jaxrs/BookServerAsyncClient.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
@@ -96,7 +97,7 @@ public class BookServerAsyncClient extends
AbstractServerTestServerBase {
public void writeTo(Boolean t, Class<?> type, Type genericType,
Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String,
Object> httpHeaders,
OutputStream os) throws IOException,
WebApplicationException {
- byte[] bytes = t.toString().getBytes("UTF-8");
+ byte[] bytes = t.toString().getBytes(StandardCharsets.UTF_8);
os.write(bytes);
}
diff --git
a/systests/transports/src/test/java/org/apache/cxf/systest/hc/jaxrs/BookServerAsyncClient.java
b/systests/transports/src/test/java/org/apache/cxf/systest/hc/jaxrs/BookServerAsyncClient.java
index 2e7610166d8..5662907fcae 100644
---
a/systests/transports/src/test/java/org/apache/cxf/systest/hc/jaxrs/BookServerAsyncClient.java
+++
b/systests/transports/src/test/java/org/apache/cxf/systest/hc/jaxrs/BookServerAsyncClient.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
import com.fasterxml.jackson.jakarta.rs.json.JacksonJsonProvider;
@@ -96,7 +97,7 @@ public class BookServerAsyncClient extends
AbstractServerTestServerBase {
public void writeTo(Boolean t, Class<?> type, Type genericType,
Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String,
Object> httpHeaders,
OutputStream os) throws IOException,
WebApplicationException {
- byte[] bytes = t.toString().getBytes("UTF-8");
+ byte[] bytes = t.toString().getBytes(StandardCharsets.UTF_8);
os.write(bytes);
}
diff --git
a/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthSupplierJettyTest.java
b/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthSupplierJettyTest.java
index b7602f05a60..a6a72edaf42 100644
---
a/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthSupplierJettyTest.java
+++
b/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthSupplierJettyTest.java
@@ -47,7 +47,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
-public class DigestAuthSupplierJettyTest extends AbstractClientServerTestBase {
+class DigestAuthSupplierJettyTest extends AbstractClientServerTestBase {
private static final String USER = "alice";
private static final String PWD = "ecila";
diff --git
a/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthSupplierSpringTest.java
b/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthSupplierSpringTest.java
index 90485528f2b..4db279372fb 100644
---
a/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthSupplierSpringTest.java
+++
b/systests/transports/src/test/java/org/apache/cxf/systest/http/auth/DigestAuthSupplierSpringTest.java
@@ -56,7 +56,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
webEnvironment = WebEnvironment.RANDOM_PORT
)
@SpringBootApplication
-public class DigestAuthSupplierSpringTest {
+class DigestAuthSupplierSpringTest {
private static final String USER = "alice";
private static final String PWD = "ecila";
@@ -65,7 +65,7 @@ public class DigestAuthSupplierSpringTest {
private int port;
@Test
- public void test() {
+ void test() {
WebClient client = WebClient.create("http://localhost:" + port,
(String) null);
assertThrows(NotAuthorizedException.class, () ->
client.get(String.class));
diff --git
a/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
index 7c7631894a2..21ab9a7afed 100644
---
a/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
+++
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
@@ -417,7 +417,7 @@ public class ClientMtomXopTest extends
AbstractBusClientServerTestBase {
}
byte[] data = new byte[(int)fileSize];
this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl").read(data);
- String stringValue = new String(data, "utf-8");
+ String stringValue = new String(data, StandardCharsets.UTF_8);
XopStringType xsv = new XopStringType();
xsv.setAttachinfo(stringValue);
xsv.setName("eman");
diff --git
a/systests/uncategorized/src/test/java/org/apache/cxf/systest/type_test/I18NStrings.java
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/type_test/I18NStrings.java
index ec461a0c37f..eda21937879 100644
---
a/systests/uncategorized/src/test/java/org/apache/cxf/systest/type_test/I18NStrings.java
+++
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/type_test/I18NStrings.java
@@ -18,6 +18,8 @@
*/
package org.apache.cxf.systest.type_test;
+import java.nio.charset.StandardCharsets;
+
public final class I18NStrings {
public static final String JAP_SIMPLE_STRING;
@@ -33,7 +35,7 @@ public final class I18NStrings {
(byte)0x0, (byte)0x65, (byte)0x69, (byte)0x1c, (byte)0x7d,
(byte)0x22,
(byte)0x69, (byte)0x1c, (byte)0x7d, (byte)0x22, (byte)0x30,
(byte)0xaa,
(byte)0x30, (byte)0xd7, (byte)0x30, (byte)0xb7, (byte)0x30,
(byte)0xe7,
- (byte)0x30, (byte)0xf3, }, "utf-16");
+ (byte)0x30, (byte)0xf3, }, StandardCharsets.UTF_16);
} catch (Exception ex) {
tmp = null;
}
@@ -167,7 +169,7 @@ public final class I18NStrings {
(byte)0xff, (byte)0x44, (byte)0xff, (byte)0x45, (byte)0xff,
(byte)0x46,
(byte)0xff, (byte)0x47, (byte)0xff, (byte)0x48, (byte)0xff,
(byte)0x49,
(byte)0xff, (byte)0x4a, (byte)0xff, (byte)0x4b, (byte)0xff,
(byte)0x4c,
- (byte)0xff, (byte)0x4d, (byte)0xff, (byte)0x4e}, "utf-16");
+ (byte)0xff, (byte)0x4d, (byte)0xff, (byte)0x4e},
StandardCharsets.UTF_16);
} catch (Exception ex) {
tmp = null;
}
diff --git
a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
index de1a77dea34..8a116e713c5 100644
---
a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
+++
b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_fromjava/WSAFromJavaTest.java
@@ -46,6 +46,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -85,14 +86,7 @@ public class WSAFromJavaTest extends AbstractWSATestBase {
AddNumberImpl port = getPort();
- try {
- port.addNumbers(-1, 2);
- } catch (AddNumbersException_Exception e) {
- assert true;
- } catch (Exception e) {
- e.printStackTrace();
- assert false;
- }
+ assertThrows(AddNumbersException_Exception.class, () ->
port.addNumbers(-1, 2));
assertTrue(output.toString().indexOf("http://cxf.apache.org/input") !=
-1);
String expectedFault =
@@ -126,14 +120,7 @@ public class WSAFromJavaTest extends AbstractWSATestBase {
AddNumberImpl port = getPort();
- try {
- port.addNumbers3(-1, 2);
- } catch (AddNumbersException_Exception e) {
- assert true;
- } catch (Exception e) {
- e.printStackTrace();
- assert false;
- }
+ assertThrows(AddNumbersException_Exception.class, () ->
port.addNumbers3(-1, 2));
assertTrue(output.toString(),
output.toString().indexOf("http://cxf.apache.org/input") != -1);
assertTrue(input.toString(),
input.toString().indexOf("http://cxf.apache.org/fault3") != -1);
diff --git
a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/WSAFromWSDLTest.java
b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/WSAFromWSDLTest.java
index ede3f795796..52e9292b85f 100644
---
a/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/WSAFromWSDLTest.java
+++
b/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_fromwsdl/WSAFromWSDLTest.java
@@ -42,6 +42,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
public class WSAFromWSDLTest extends AbstractWSATestBase {
@@ -121,14 +122,7 @@ public class WSAFromWSDLTest extends AbstractWSATestBase {
AddNumbersPortType port = getPort();
- try {
- port.addNumbers(-1, 2);
- } catch (AddNumbersFault_Exception ex) {
- assert true;
- } catch (Exception e) {
- e.printStackTrace();
- assert false;
- }
+ assertThrows(AddNumbersFault_Exception.class, () ->
port.addNumbers(-1, 2));
String expectedOut = BASE_URI + "addNumbersRequest";
String expectedIn = BASE_URI + "addNumbers/Fault/addNumbersFault";
@@ -144,14 +138,7 @@ public class WSAFromWSDLTest extends AbstractWSATestBase {
try (AddNumbersPortTypeProxy port = getPort()) {
- try {
- port.addNumbers3(-1, 2);
- } catch (AddNumbersFault_Exception ex) {
- assert true;
- } catch (Exception e) {
- e.printStackTrace();
- assert false;
- }
+ assertThrows(AddNumbersFault_Exception.class, () ->
port.addNumbers3(-1, 2));
String expectedOut = "3in";
String expectedIn = "3fault";
diff --git
a/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
b/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
index 7070375be85..5fed87bc92d 100644
--- a/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
+++ b/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
@@ -255,6 +255,7 @@ public class ServerLauncher {
return ret;
}
+ @SuppressWarnings("PMD.OverridingThreadRun")
private class OutputMonitorThread extends Thread {
InputStream in;
StringBuilder serverOutputAll = new StringBuilder();
diff --git
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/IncludeStackEntry.java
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/IncludeStackEntry.java
index bce2d917a5b..4453934caf2 100644
---
a/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/IncludeStackEntry.java
+++
b/tools/corba/src/main/java/org/apache/cxf/tools/corba/idlpreprocessor/IncludeStackEntry.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
/**
* Provides information about a file that
@@ -37,7 +38,7 @@ class IncludeStackEntry {
IncludeStackEntry(URL link, String loc) throws IOException {
this.url = link;
this.location = loc;
- this.reader = new LineNumberReader(new
InputStreamReader(url.openStream(), "ISO-8859-1"));
+ this.reader = new LineNumberReader(new
InputStreamReader(url.openStream(), StandardCharsets.ISO_8859_1));
this.reader.setLineNumber(1);
}
diff --git
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReaderTest.java
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReaderTest.java
index 3d37a2420a6..f6672cc4852 100644
---
a/tools/corba/src/test/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReaderTest.java
+++
b/tools/corba/src/test/java/org/apache/cxf/tools/corba/idlpreprocessor/IdlPreprocessorReaderTest.java
@@ -26,6 +26,7 @@ import java.io.LineNumberReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.regex.Pattern;
@@ -135,7 +136,7 @@ public class IdlPreprocessorReaderTest {
LineNumberReader oReader = new LineNumberReader(includeReader);
InputStream resolved =
findTestResource(expectedResultLocation).openStream();
try (LineNumberReader rReader
- = new LineNumberReader(new InputStreamReader(resolved,
"ISO-8859-1"))) {
+ = new LineNumberReader(new InputStreamReader(resolved,
StandardCharsets.ISO_8859_1))) {
boolean eof;
do {
int line = rReader.getLineNumber() + 1;
diff --git
a/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidatorUtil.java
b/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidatorUtil.java
index df959a698b6..1ddb0bfb1e8 100644
---
a/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidatorUtil.java
+++
b/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/ValidatorUtil.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -88,7 +89,7 @@ public final class ValidatorUtil {
}
synchronized (document) {
// URL might need encoding for special characters.
- baseURI = URLEncoder.encode(baseURI, "utf-8");
+ baseURI = URLEncoder.encode(baseURI, StandardCharsets.UTF_8);
SchemaCollection schemaCol = new SchemaCollection();
schemaCol.setBaseUri(baseURI);