This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch 3.6.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 625e3d24f40713a222b754f9c1ad60be194b37f0
Author: neseleznev <ne.selez...@gmail.com>
AuthorDate: Tue Nov 15 17:44:07 2022 +0200

    CXF-8698: Refactor signature, remove exception which never occurs
    
    (cherry picked from commit 0971a69286b9ea781d1ce6eb137b4488981e46ae)
---
 .../java/org/apache/cxf/attachment/AttachmentUtil.java | 18 ++++--------------
 .../org/apache/cxf/attachment/AttachmentUtilTest.java  | 10 +++++-----
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java 
b/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
index 0cb4da7834..d2f751acb8 100644
--- a/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
+++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
@@ -252,7 +252,7 @@ public final class AttachmentUtil {
      * @param ns namespace. If null, falls back to "cxf.apache.org"
      * @return Content ID
      */
-    public static String createContentID(String ns) throws 
UnsupportedEncodingException {
+    public static String createContentID(String ns) {
         // tend to change
         String cid = "cxf.apache.org";
         if (ns != null && !ns.isEmpty()) {
@@ -269,7 +269,7 @@ public final class AttachmentUtil {
             }
         }
         return ATT_UUID + '-' + Integer.toString(COUNTER.incrementAndGet()) + 
'@'
-            + URLEncoder.encode(cid, StandardCharsets.UTF_8.name());
+            + URLEncoder.encode(cid, StandardCharsets.UTF_8);
     }
 
     public static String getUniqueBoundaryValue() {
@@ -509,12 +509,7 @@ public final class AttachmentUtil {
         source.setContentType(mimeType);
         DataHandler handler = new DataHandler(source);
 
-        String id;
-        try {
-            id = AttachmentUtil.createContentID(elementNS);
-        } catch (UnsupportedEncodingException e) {
-            throw new Fault(e);
-        }
+        String id = AttachmentUtil.createContentID(elementNS);
         AttachmentImpl att = new AttachmentImpl(id, handler);
         att.setXOP(isXop);
         return att;
@@ -549,12 +544,7 @@ public final class AttachmentUtil {
         //      ignore, just do the normal attachment thing
         }
 
-        String id;
-        try {
-            id = AttachmentUtil.createContentID(elementNS);
-        } catch (UnsupportedEncodingException e) {
-            throw new Fault(e);
-        }
+        String id = AttachmentUtil.createContentID(elementNS);
         AttachmentImpl att = new AttachmentImpl(id, handler);
         if (!StringUtils.isEmpty(handler.getName())) {
             //set Content-Disposition attachment header if filename isn't null
diff --git 
a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java 
b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java
index 2c3b5f36b4..ebe7dc8db2 100644
--- a/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java
+++ b/core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java
@@ -138,7 +138,7 @@ public class AttachmentUtilTest {
     }
 
     @Test
-    public void testCreateContentIDWithNullDomainNamePassed() throws Exception 
{
+    public void testCreateContentIDWithNullDomainNamePassed() {
         String actual = AttachmentUtil.createContentID(null);
 
         // Yet RFC822 allows more characters in domain-literal,
@@ -147,7 +147,7 @@ public class AttachmentUtilTest {
     }
 
     @Test
-    public void testCreateContentIDWithDomainNamePassed() throws Exception {
+    public void testCreateContentIDWithDomainNamePassed() {
         String domain = "subdomain.example.com";
 
         String actual = AttachmentUtil.createContentID(domain);
@@ -156,7 +156,7 @@ public class AttachmentUtilTest {
     }
 
     @Test
-    public void testCreateContentIDWithUrlPassed() throws Exception {
+    public void testCreateContentIDWithUrlPassed() {
         String domain = "subdomain.example.com";
         String url = "https://"; + domain + "/a/b/c";
 
@@ -166,7 +166,7 @@ public class AttachmentUtilTest {
     }
 
     @Test
-    public void testCreateContentIDWithIPv4BasedUrlPassed() throws Exception {
+    public void testCreateContentIDWithIPv4BasedUrlPassed() {
         String domain = "127.0.0.1";
         String url = "https://"; + domain + "/a/b/c";
 
@@ -177,7 +177,7 @@ public class AttachmentUtilTest {
 
     @Test
     @Ignore //TODO:8698 Content-Id should contain valid domain, but IPv6 input 
results in URL-encoded string
-    public void testCreateContentIDWithIPv6BasedUrlPassed() throws Exception {
+    public void testCreateContentIDWithIPv6BasedUrlPassed() {
         String domain = "[2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d]";
         String url = "http://"; + domain + "/a/b/c";
 

Reply via email to