You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2017/12/02 20:38:36 UTC
svn commit: r1816984 - in /tomcat/trunk:
java/org/apache/catalina/tribes/io/ChannelData.java
java/org/apache/catalina/tribes/io/XByteBuffer.java
test/org/apache/catalina/tribes/io/TestChannelData.java
Author: markt
Date: Sat Dec 2 20:38:36 2017
New Revision: 1816984
URL: http://svn.apache.org/viewvc?rev=1816984&view=rev
Log:
Spotbugs fixes (rank >=16) in tribes.io
Added:
tomcat/trunk/test/org/apache/catalina/tribes/io/TestChannelData.java (with props)
Modified:
tomcat/trunk/java/org/apache/catalina/tribes/io/ChannelData.java
tomcat/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java
Modified: tomcat/trunk/java/org/apache/catalina/tribes/io/ChannelData.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/io/ChannelData.java?rev=1816984&r1=1816983&r2=1816984&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/io/ChannelData.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/io/ChannelData.java Sat Dec 2 20:38:36 2017
@@ -302,15 +302,17 @@ public class ChannelData implements Chan
* @return ClusterData
*/
@Override
- public Object clone() {
-// byte[] d = this.getDataPackage();
-// return ClusterData.getDataFromPackage(d);
- ChannelData clone = new ChannelData(false);
- clone.options = this.options;
- clone.message = new XByteBuffer(this.message.getBytesDirect(),false);
- clone.timestamp = this.timestamp;
- clone.uniqueId = this.uniqueId;
- clone.address = this.address;
+ public ChannelData clone() {
+ ChannelData clone;
+ try {
+ clone = (ChannelData) super.clone();
+ } catch (CloneNotSupportedException e) {
+ // Cannot happen
+ throw new AssertionError();
+ }
+ if (this.message != null) {
+ clone.message = new XByteBuffer(this.message.getBytesDirect(),false);
+ }
return clone;
}
Modified: tomcat/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java?rev=1816984&r1=1816983&r2=1816984&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/io/XByteBuffer.java Sat Dec 2 20:38:36 2017
@@ -47,7 +47,9 @@ import org.apache.juli.logging.LogFactor
* <li><b>END_DATA</b> - 7 bytes - <i>TLF2003</i></li>
* </ul>
*/
-public class XByteBuffer {
+public class XByteBuffer implements Serializable {
+
+ private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(XByteBuffer.class);
protected static final StringManager sm = StringManager.getManager(XByteBuffer.class);
Added: tomcat/trunk/test/org/apache/catalina/tribes/io/TestChannelData.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/io/TestChannelData.java?rev=1816984&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/io/TestChannelData.java (added)
+++ tomcat/trunk/test/org/apache/catalina/tribes/io/TestChannelData.java Sat Dec 2 20:38:36 2017
@@ -0,0 +1,33 @@
+/*
+ * 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.catalina.tribes.io;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestChannelData {
+
+ @Test
+ public void testClone() {
+ ChannelData original = new ChannelData();
+ ChannelData clone = original.clone();
+
+ Assert.assertFalse(original == clone);
+ Assert.assertTrue(original.getClass() == clone.getClass());
+ Assert.assertTrue(original.equals(clone));
+ }
+}
Propchange: tomcat/trunk/test/org/apache/catalina/tribes/io/TestChannelData.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org