struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4982) Remove the deprecated JsonLibHandler and outdated json-lib dependency
Date Sun, 18 Nov 2018 10:46:00 GMT

    [ https://issues.apache.org/jira/browse/WW-4982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16690858#comment-16690858
] 

ASF GitHub Bot commented on WW-4982:
------------------------------------

lukaszlenart closed pull request #273: WW-4982 Remove the deprecated JsonLibHandler and json-lib
dependency
URL: https://github.com/apache/struts/pull/273
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/assembly/src/main/resources/NOTICE.txt b/assembly/src/main/resources/NOTICE.txt
index 3e10af889..cec81a249 100644
--- a/assembly/src/main/resources/NOTICE.txt
+++ b/assembly/src/main/resources/NOTICE.txt
@@ -11,7 +11,6 @@ ANTLR (http://www.antlr.org/).
 Classworlds (http://classworlds.codehaus.org/).
 EZMorph (http://ezmorph.sourceforge.net/)
 FreeMarker (http://freemarker.org/).
-JSON-lib (http://json-lib.sourceforge.net/).
 OGNL (http://www.opensymphony.com/ognl/).
 Plexus (http://plexus.codehaus.org/).
 SiteMesh (http://www.opensymphony.com/sitemesh/).
diff --git a/plugins/rest/pom.xml b/plugins/rest/pom.xml
index d3dfc1d32..88a7d9750 100644
--- a/plugins/rest/pom.xml
+++ b/plugins/rest/pom.xml
@@ -40,12 +40,6 @@
             <groupId>com.thoughtworks.xstream</groupId>
             <artifactId>xstream</artifactId>
         </dependency>
-        <dependency>
-            <groupId>net.sf.json-lib</groupId>
-            <artifactId>json-lib</artifactId>
-            <classifier>jdk15</classifier>
-            <optional>true</optional>
-        </dependency>
 
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
diff --git a/plugins/rest/src/main/java/org/apache/struts2/rest/handler/JsonLibHandler.java
b/plugins/rest/src/main/java/org/apache/struts2/rest/handler/JsonLibHandler.java
deleted file mode 100644
index 84b19d875..000000000
--- a/plugins/rest/src/main/java/org/apache/struts2/rest/handler/JsonLibHandler.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.struts2.rest.handler;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.Collection;
-
-import com.opensymphony.xwork2.ActionInvocation;
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-import net.sf.json.JsonConfig;
-
-import org.apache.struts2.StrutsConstants;
-
-import com.opensymphony.xwork2.inject.Inject;
-
-/**
- * Handles JSON content using json-lib
- *
- * @deprecated Use {@link JacksonLibHandler} instead
- */
-@Deprecated
-public class JsonLibHandler extends AbstractContentTypeHandler {
-
-    private static final String DEFAULT_CONTENT_TYPE = "application/json";
-    private String defaultEncoding = "ISO-8859-1";
-
-    public void toObject(ActionInvocation invocation, Reader in, Object target) throws IOException
{
-        StringBuilder sb = new StringBuilder();
-        char[] buffer = new char[1024];
-        int len = 0;
-        while ((len = in.read(buffer)) > 0) {
-            sb.append(buffer, 0, len);
-        }
-        if (target != null && sb.length() > 0 && sb.charAt(0) == '[')
{
-            JSONArray jsonArray = JSONArray.fromObject(sb.toString());
-            if (target.getClass().isArray()) {
-                JSONArray.toArray(jsonArray, target, new JsonConfig());
-            } else {
-                JSONArray.toList(jsonArray, target, new JsonConfig());
-            }
-
-        } else {
-            JSONObject jsonObject = JSONObject.fromObject(sb.toString());
-            JSONObject.toBean(jsonObject, target, new JsonConfig());
-        }
-    }
-
-    public String fromObject(ActionInvocation invocation, Object obj, String resultCode,
Writer stream) throws IOException {
-        if (obj != null) {
-            if (isArray(obj)) {
-                JSONArray jsonArray = JSONArray.fromObject(obj);
-                stream.write(jsonArray.toString());
-            } else {
-                JSONObject jsonObject = JSONObject.fromObject(obj);
-                stream.write(jsonObject.toString());
-            }
-        }
-        return null;
-
-
-    }
-
-    private boolean isArray(Object obj) {
-        return obj instanceof Collection || obj.getClass().isArray();
-    }
-
-    public String getContentType() {
-        return DEFAULT_CONTENT_TYPE+";charset=" + this.defaultEncoding;
-    }
-    
-    public String getExtension() {
-        return "json";
-    }
-    
-    @Inject(StrutsConstants.STRUTS_I18N_ENCODING)
-    public void setDefaultEncoding(String val) {
-        this.defaultEncoding = val;
-    }
-}
diff --git a/plugins/rest/src/main/resources/NOTICE.txt b/plugins/rest/src/main/resources/NOTICE.txt
index e40c2ae0e..773ca9490 100644
--- a/plugins/rest/src/main/resources/NOTICE.txt
+++ b/plugins/rest/src/main/resources/NOTICE.txt
@@ -6,6 +6,5 @@ The Apache Software Foundation (http://www.apache.org/).
 
 The binary distributions includes the following third party software:
 EZMorph (http://ezmorph.sourceforge.net/)
-JSON-lib (http://json-lib.sourceforge.net/).
 XPP3 (http://www.extreme.indiana.edu/xgws/xsoap/xpp/).
 XStream (http://xstream.codehaus.org/).
diff --git a/plugins/rest/src/test/java/org/apache/struts2/rest/handler/JsonLibHandlerTest.java
b/plugins/rest/src/test/java/org/apache/struts2/rest/handler/JsonLibHandlerTest.java
deleted file mode 100644
index 122d59cce..000000000
--- a/plugins/rest/src/test/java/org/apache/struts2/rest/handler/JsonLibHandlerTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.struts2.rest.handler;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.Arrays;
-
-import com.opensymphony.xwork2.mock.MockActionInvocation;
-import junit.framework.TestCase;
-
-public class JsonLibHandlerTest extends TestCase {
-
-    public void testFromObject() throws IOException {
-        Contact contact = new Contact("bob", true, 44);
-
-        StringWriter writer = new StringWriter();
-        JsonLibHandler handler = new JsonLibHandler();
-        handler.fromObject(new MockActionInvocation(), contact, "success", writer);
-        String data = writer.toString();
-        assertTrue(data.startsWith("{"));
-        assertTrue(data.contains("\"age\":44"));
-        assertTrue(data.contains("\"important\":true"));
-        assertTrue(data.contains("\"name\":\"bob\""));
-    }
-
-    public void testFromObjectArray() throws IOException {
-        Contact contact = new Contact("bob", true, 44);
-
-        StringWriter writer = new StringWriter();
-        JsonLibHandler handler = new JsonLibHandler();
-        handler.fromObject(new MockActionInvocation(), Arrays.asList(contact), "success",
writer);
-
-        String data = writer.toString();
-        assertTrue(data.startsWith("[{"));
-        assertTrue(data.contains("\"age\":44"));
-        assertTrue(data.contains("\"important\":true"));
-        assertTrue(data.contains("\"name\":\"bob\""));
-    }
-
-    public void testToObject() throws IOException {
-        Contact contact = new Contact("bob", true, 44);
-
-        Contact target = new Contact();
-        StringReader reader = new StringReader("{\"age\":44,\"important\":true,\"name\":\"bob\"}");
-        JsonLibHandler handler = new JsonLibHandler();
-        handler.toObject(new MockActionInvocation(), reader, target);
-
-        assertEquals(contact, target);
-    }
-
-    public void testContentType() throws IOException {
-        JsonLibHandler handler = new JsonLibHandler();
-        assertEquals(handler.getContentType(), "application/json;charset=ISO-8859-1");
-    }
-    
-    public void testDefaultEncoding() throws IOException {
-        JsonLibHandler handler = new JsonLibHandler();
-        handler.setDefaultEncoding("UTF-8");
-        assertEquals(handler.getContentType(), "application/json;charset=UTF-8");
-    }
-}
diff --git a/pom.xml b/pom.xml
index b195d2b3a..9f6ccbe9b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1053,13 +1053,6 @@
                 <version>2.0</version>
             </dependency>
 
-            <dependency>
-                <groupId>net.sf.json-lib</groupId>
-                <artifactId>json-lib</artifactId>
-                <classifier>jdk15</classifier>
-                <version>2.4</version>
-            </dependency>
-
             <dependency>
                 <groupId>com.fasterxml.jackson.core</groupId>
                 <artifactId>jackson-core</artifactId>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Remove the deprecated JsonLibHandler and outdated json-lib dependency
> ---------------------------------------------------------------------
>
>                 Key: WW-4982
>                 URL: https://issues.apache.org/jira/browse/WW-4982
>             Project: Struts 2
>          Issue Type: Task
>          Components: Plugin - REST
>            Reporter: Sebastian Peters
>            Priority: Trivial
>             Fix For: 2.6
>
>
> JsonLibHandler has been deprecated with WW-4892 in version [2.5.14.1|https://issues.apache.org/jira/issues/?jql=project+%3D+WW+AND+fixVersion+%3D+2.5.14.1] and
could be removed for 2.6.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message