Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 556E1200BAE for ; Fri, 28 Oct 2016 23:40:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 54331160B09; Fri, 28 Oct 2016 21:40:36 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E938E160AF5 for ; Fri, 28 Oct 2016 23:40:34 +0200 (CEST) Received: (qmail 1435 invoked by uid 500); 28 Oct 2016 21:40:34 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 1353 invoked by uid 99); 28 Oct 2016 21:40:34 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Oct 2016 21:40:34 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 8F68BC1A35 for ; Fri, 28 Oct 2016 21:40:33 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id DfkxoRJZyma0 for ; Fri, 28 Oct 2016 21:40:30 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 45A645FC7D for ; Fri, 28 Oct 2016 21:40:17 +0000 (UTC) Received: (qmail 98093 invoked by uid 99); 28 Oct 2016 21:40:16 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Oct 2016 21:40:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1EA8FF16AD; Fri, 28 Oct 2016 21:40:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dschneider@apache.org To: commits@geode.incubator.apache.org Date: Fri, 28 Oct 2016 21:40:49 -0000 Message-Id: <861d4cf1088e48a6ab9160e9ee6ad05a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [35/98] [abbrv] [partial] incubator-geode git commit: Added Spotless plugin to enforce formatting standards. Added Google Java Style guide formatter templates, removed existing formatter templates. archived-at: Fri, 28 Oct 2016 21:40:36 -0000 http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/CancelCriterion.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/CancelCriterion.java b/geode-core/src/main/java/org/apache/geode/CancelCriterion.java index f0eb160..e4f9a41 100644 --- a/geode-core/src/main/java/org/apache/geode/CancelCriterion.java +++ b/geode-core/src/main/java/org/apache/geode/CancelCriterion.java @@ -1,32 +1,29 @@ /* - * 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 + * 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 + * 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. + * 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.geode; /** * Abstract cancellation proxy for cancelling an operation, esp. a thread. * - * Creators of services or threads should implement a subclass of CancelCriterion, - * and implement the two methods - cancelInProgress, and generateCancelledException(e). + * Creators of services or threads should implement a subclass of CancelCriterion, and implement the + * two methods - cancelInProgress, and generateCancelledException(e). * * Code inside the service can check to see if the service is cancelled by calling - * {@link #checkCancelInProgress(Throwable)}. Generally the pattern is to check - * before performing an operation, check if the service is canceled before propgrating - * an exception futher up the stack, and check for cancelation inside a long loop. - * Eg. + * {@link #checkCancelInProgress(Throwable)}. Generally the pattern is to check before performing an + * operation, check if the service is canceled before propgrating an exception futher up the stack, + * and check for cancelation inside a long loop. Eg. * * * while(true) { @@ -43,25 +40,25 @@ package org.apache.geode; * @see CancelException * @since GemFire 5.1 */ -public abstract class CancelCriterion -{ - +public abstract class CancelCriterion { + /** - * Indicate if the service is in the progress of being cancelled. The - * typical use of this is to indicate, in the case of an {@link InterruptedException}, - * that the current operation should be cancelled. - * @return null if the service is not shutting down, or a message that can be used to - * construct an exception indicating the service is shut down. + * Indicate if the service is in the progress of being cancelled. The typical use of this is to + * indicate, in the case of an {@link InterruptedException}, that the current operation should be + * cancelled. + * + * @return null if the service is not shutting down, or a message that can be used to construct an + * exception indicating the service is shut down. */ public abstract String cancelInProgress(); -//import org.apache.geode.distributed.internal.DistributionManager; -// *

-// * In particular, a {@link DistributionManager} returns a non-null result if -// * message distribution has been terminated. - + // import org.apache.geode.distributed.internal.DistributionManager; + // *

+ // * In particular, a {@link DistributionManager} returns a non-null result if + // * message distribution has been terminated. + /** - * Use this utility function in your implementation of cancelInProgress() - * and cancelled() to indicate a system failure + * Use this utility function in your implementation of cancelInProgress() and cancelled() to + * indicate a system failure * * @return failure string if system failure has occurred */ @@ -75,11 +72,10 @@ public abstract class CancelCriterion } /** - * See if the current operation is being cancelled. If so, it either - * throws a {@link RuntimeException} (usually a {@link CancelException}). + * See if the current operation is being cancelled. If so, it either throws a + * {@link RuntimeException} (usually a {@link CancelException}). * - * @param e an underlying exception or null if there is no exception - * that triggered this check + * @param e an underlying exception or null if there is no exception that triggered this check * @see #cancelInProgress() */ public final void checkCancelInProgress(Throwable e) { @@ -93,23 +89,21 @@ public abstract class CancelCriterion /** * Template factory method for generating the exception to be thrown by - * {@link #checkCancelInProgress(Throwable)}. Override this to specify - * different exception for checkCancelInProgress() to throw. + * {@link #checkCancelInProgress(Throwable)}. Override this to specify different exception for + * checkCancelInProgress() to throw. * - * This method should wrap the exception in a service specific - * CancelationException (eg CacheClosedException). - * or return null if the service is not being canceled. + * This method should wrap the exception in a service specific CancelationException (eg + * CacheClosedException). or return null if the service is not being canceled. * - * @param e - * an underlying exception, if any - * @return RuntimeException to be thrown by checkCancelInProgress(), null if - * the receiver has not been cancelled. + * @param e an underlying exception, if any + * @return RuntimeException to be thrown by checkCancelInProgress(), null if the receiver has not + * been cancelled. */ abstract public RuntimeException generateCancelledException(Throwable e); /** - * Checks to see if a cancellation is in progress. This is equivalent to - * the expression (cancelInProgress() != null). + * Checks to see if a cancellation is in progress. This is equivalent to the expression + * (cancelInProgress() != null). * * @return true if a cancellation is in progress, false if not */ http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/CancelException.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/CancelException.java b/geode-core/src/main/java/org/apache/geode/CancelException.java index 422036a..49413f2 100644 --- a/geode-core/src/main/java/org/apache/geode/CancelException.java +++ b/geode-core/src/main/java/org/apache/geode/CancelException.java @@ -1,18 +1,16 @@ /* - * 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 + * 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 + * 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. + * 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. */ /** * @@ -22,8 +20,7 @@ package org.apache.geode; import org.apache.geode.cache.CacheRuntimeException; /** - * Abstract root class of all GemFire exceptions representing system - * cancellation + * Abstract root class of all GemFire exceptions representing system cancellation * * @since GemFire 6.0 */ @@ -33,11 +30,11 @@ public abstract class CancelException extends CacheRuntimeException { /** * for serialization */ - public CancelException() { - } + public CancelException() {} /** * Create instance with given message + * * @param message the message */ public CancelException(String message) { @@ -46,6 +43,7 @@ public abstract class CancelException extends CacheRuntimeException { /** * Create instance with given message and cause + * * @param message the message * @param cause the cause */ @@ -55,6 +53,7 @@ public abstract class CancelException extends CacheRuntimeException { /** * Create instance with empty message and given cause + * * @param cause the cause */ public CancelException(Throwable cause) { http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/CanonicalInstantiator.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/CanonicalInstantiator.java b/geode-core/src/main/java/org/apache/geode/CanonicalInstantiator.java index d62d873..10e6f16 100644 --- a/geode-core/src/main/java/org/apache/geode/CanonicalInstantiator.java +++ b/geode-core/src/main/java/org/apache/geode/CanonicalInstantiator.java @@ -1,69 +1,55 @@ /* - * 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 + * 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 + * 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. + * 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.geode; import java.io.*; /** - * CanonicalInstantiator is much like its parent - * Instantiator except that instead of - * needing to implement newInstance() - * you now must implement newInstance(DataInput). - * The addition of the DataInput parameter allows the instance - * creator to optionally read data from the data input stream and use it to - * decide the instance to create. This allows a value that represents a - * canonical instance to be written by a class's {@link DataSerializer#toData} - * and then be read by newInstance(DataInput) - * and map it back to a canonical instance. + * CanonicalInstantiator is much like its parent Instantiator except that + * instead of needing to implement newInstance() you now must implement + * newInstance(DataInput). The addition of the DataInput parameter allows + * the instance creator to optionally read data from the data input stream and use it to decide the + * instance to create. This allows a value that represents a canonical instance to be written by a + * class's {@link DataSerializer#toData} and then be read by newInstance(DataInput) and + * map it back to a canonical instance. *

- * Note that {@link DataSerializer#fromData} is always called on the instance - * returned from newInstance(DataInput). + * Note that {@link DataSerializer#fromData} is always called on the instance returned from + * newInstance(DataInput). * * @since GemFire 5.1 */ public abstract class CanonicalInstantiator extends Instantiator { /** - * Creates a new CanonicalInstantiator that instantiates a given - * class. + * Creates a new CanonicalInstantiator that instantiates a given class. * - * @param c - * The DataSerializable class to register. This - * class must have a static initializer that registers this - * Instantiator. - * @param classId - * A unique id for class c. The - * classId must not be zero. + * @param c The DataSerializable class to register. This class must have a static + * initializer that registers this Instantiator. + * @param classId A unique id for class c. The classId must not be zero. * This has been an int since dsPhase1. * - * @throws IllegalArgumentException - * If c does not implement - * DataSerializable, classId is - * less than or equal to zero. - * @throws NullPointerException - * If c is null + * @throws IllegalArgumentException If c does not implement + * DataSerializable, classId is less than or equal to zero. + * @throws NullPointerException If c is null */ public CanonicalInstantiator(Class c, int classId) { super(c, classId); } - + /** - * This method is not supported and if called will - * throw UnsupportedOperationException. - * Use {@link #newInstance(DataInput)} instead. + * This method is not supported and if called will throw UnsupportedOperationException. Use + * {@link #newInstance(DataInput)} instead. * * @throws UnsupportedOperationException in all cases */ @@ -71,15 +57,15 @@ public abstract class CanonicalInstantiator extends Instantiator { public final DataSerializable newInstance() { throw new UnsupportedOperationException(); } + /** - * Creates a new "empty" instance of a DataSerializable - * class whose state will be filled in by invoking its - * {@link DataSerializable#fromData fromData} method. + * Creates a new "empty" instance of a DataSerializable class whose state will be + * filled in by invoking its {@link DataSerializable#fromData fromData} method. + * * @param in the data input that can be read to decide what instance to create. * @return the new "empty" instance. * @throws IOException if a read from in fails. * @since GemFire 5.1 */ - public abstract DataSerializable newInstance(DataInput in) - throws IOException; + public abstract DataSerializable newInstance(DataInput in) throws IOException; } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/CopyException.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/CopyException.java b/geode-core/src/main/java/org/apache/geode/CopyException.java index 8ad9c57..00ad5da 100644 --- a/geode-core/src/main/java/org/apache/geode/CopyException.java +++ b/geode-core/src/main/java/org/apache/geode/CopyException.java @@ -1,18 +1,16 @@ /* - * 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 + * 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 + * 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. + * 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.geode; @@ -25,15 +23,15 @@ package org.apache.geode; * @since GemFire 4.0 */ public class CopyException extends GemFireException { -private static final long serialVersionUID = -1143711608610323585L; - + private static final long serialVersionUID = -1143711608610323585L; + /** * Constructs a new CopyException. */ public CopyException() { super(); } - + /** * Constructs a new CopyException with a message string. * @@ -42,10 +40,9 @@ private static final long serialVersionUID = -1143711608610323585L; public CopyException(String msg) { super(msg); } - + /** - * Constructs a new CopyException with a message string - * and a cause. + * Constructs a new CopyException with a message string and a cause. * * @param msg the message string * @param cause a causal Throwable @@ -53,7 +50,7 @@ private static final long serialVersionUID = -1143711608610323585L; public CopyException(String msg, Throwable cause) { super(msg, cause); } - + /** * Constructs a new CopyException with a cause. * http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/CopyHelper.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/CopyHelper.java b/geode-core/src/main/java/org/apache/geode/CopyHelper.java index dd79c0e..86592c0 100644 --- a/geode-core/src/main/java/org/apache/geode/CopyHelper.java +++ b/geode-core/src/main/java/org/apache/geode/CopyHelper.java @@ -1,20 +1,19 @@ /* - * 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 + * 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 + * 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. + * 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.geode; + import java.io.DataInputStream; import java.io.IOException; import java.io.Serializable; @@ -35,19 +34,19 @@ import org.apache.geode.pdx.WritablePdxInstance; import org.apache.geode.pdx.internal.PdxUnreadData; /** - * A static helper for optimally creating copies. Creating copies - * of cache values provides improved concurrency as well as isolation. - * For transactions, creating a copy is the guaranteed way to enforce - * "Read Committed" isolation on changes to cache - * Entries. - - *

Here is a simple example of how to use CopyHelper.copy - *

- *    Object o = r.get("stringBuf");
- *    StringBuffer s = (StringBuffer) CopyHelper.copy(o);
- *    s.append("... and they lived happily ever after.  The End.");
- *    r.put("stringBuf", s);
- *  
+ * A static helper for optimally creating copies. Creating copies of cache values provides improved + * concurrency as well as isolation. For transactions, creating a copy is the guaranteed way to + * enforce "Read Committed" isolation on changes to cache Entries. + * + *

+ * Here is a simple example of how to use CopyHelper.copy + * + *

+ * Object o = r.get("stringBuf");
+ * StringBuffer s = (StringBuffer) CopyHelper.copy(o);
+ * s.append("... and they lived happily ever after.  The End.");
+ * r.put("stringBuf", s);
+ * 
* * @see Cloneable * @see Serializable @@ -61,13 +60,11 @@ import org.apache.geode.pdx.internal.PdxUnreadData; public final class CopyHelper { // no instances allowed - private CopyHelper() { - } + private CopyHelper() {} /** - * Return true if the given object is an instance of a well known - * immutable class. - * The well known classes are: + * Return true if the given object is an instance of a well known immutable class. The well known + * classes are: *
    *
  • String *
  • Byte @@ -82,6 +79,7 @@ public final class CopyHelper { *
  • UUID *
  • PdxInstance but not WritablePdxInstance *
+ * * @param o the object to check * @return true if o is an instance of a well known immutable class. * @since GemFire 6.6.2 @@ -91,48 +89,62 @@ public final class CopyHelper { return true; } if (o instanceof Number) { - if (o instanceof Integer) return true; - if (o instanceof Long) return true; - if (o instanceof Byte) return true; - if (o instanceof Short) return true; - if (o instanceof Float) return true; - if (o instanceof Double) return true; + if (o instanceof Integer) + return true; + if (o instanceof Long) + return true; + if (o instanceof Byte) + return true; + if (o instanceof Short) + return true; + if (o instanceof Float) + return true; + if (o instanceof Double) + return true; // subclasses of non-final classes may be mutable - if (o.getClass().equals(BigInteger.class)) return true; - if (o.getClass().equals(BigDecimal.class)) return true; + if (o.getClass().equals(BigInteger.class)) + return true; + if (o.getClass().equals(BigDecimal.class)) + return true; } if (o instanceof PdxInstance && !(o instanceof WritablePdxInstance)) { // no need to copy since it is immutable return true; } - if (o instanceof Character) return true; - if (o instanceof UUID) return true; + if (o instanceof Character) + return true; + if (o instanceof UUID) + return true; return false; } + /** - *

Makes a copy of the specified object. The object returned is not guaranteed - * to be a deep copy of the original object, as explained below. + *

+ * Makes a copy of the specified object. The object returned is not guaranteed to be a deep copy + * of the original object, as explained below. * - *

Copies can only be made if the original is a Cloneable or serializable by - * GemFire. - * If o is a {@link #isWellKnownImmutableInstance(Object) well known immutable instance} - * then it will be returned without copying it. + *

+ * Copies can only be made if the original is a Cloneable or serializable by GemFire. If + * o is a {@link #isWellKnownImmutableInstance(Object) well known immutable instance} then it will + * be returned without copying it. * - *

If the argument o is an instance of {@link java.lang.Cloneable}, a copy is - * made by invoking clone on it. Note that not all implementations of clone - * make deep copies (e.g. {@link java.util.HashMap#clone HashMap.clone}). Otherwise, if the - * argument is not an instance of Cloneable, a copy is made using serialization: if - * GemFire serialization is implemented, it is used; otherwise, java serialization is used. + *

+ * If the argument o is an instance of {@link java.lang.Cloneable}, a copy is made by invoking + * clone on it. Note that not all implementations of clone make deep copies + * (e.g. {@link java.util.HashMap#clone HashMap.clone}). Otherwise, if the argument is not an + * instance of Cloneable, a copy is made using serialization: if GemFire serialization is + * implemented, it is used; otherwise, java serialization is used. * - *

The difference between this method and {@link #deepCopy(Object) deepCopy}, is that - * this method uses clone if available, whereas deepCopy does not. As a - * result, for Cloneable objects copied using this method, how deep a copy the - * returned object is depends on its implementation of clone. + *

+ * The difference between this method and {@link #deepCopy(Object) deepCopy}, is that this method + * uses clone if available, whereas deepCopy does not. As a result, for + * Cloneable objects copied using this method, how deep a copy the returned object is + * depends on its implementation of clone. * * @param o the original object that a copy is needed of * @return the new instance that is a copy of of the original - * @throws CopyException if copying fails because a class could not - * be found or could not be serialized. + * @throws CopyException if copying fails because a class could not be found or could not be + * serialized. * @see #deepCopy(Object) * @since GemFire 4.0 */ @@ -145,7 +157,8 @@ public final class CopyHelper { } else if (o instanceof Token) { return o; } else { - if (isWellKnownImmutableInstance(o)) return o; + if (isWellKnownImmutableInstance(o)) + return o; if (o instanceof Cloneable) { try { // Note that Object.clone is protected so we need to use reflection @@ -158,7 +171,7 @@ public final class CopyHelper { // because Object.clone is protected. Method m = c.getDeclaredMethod("clone", new Class[0]); m.setAccessible(true); - copy = (T)m.invoke(o, new Object[0]); + copy = (T) m.invoke(o, new Object[0]); return copy; } catch (NoSuchMethodException ignore) { // try using Serialization @@ -171,7 +184,8 @@ public final class CopyHelper { if (cause instanceof CloneNotSupportedException) { // try using Serialization } else { - throw new CopyException(LocalizedStrings.CopyHelper_CLONE_FAILED.toLocalizedString(), cause != null ? cause : ex); + throw new CopyException(LocalizedStrings.CopyHelper_CLONE_FAILED.toLocalizedString(), + cause != null ? cause : ex); } } } else if (o instanceof CachedDeserializable) { @@ -179,28 +193,28 @@ public final class CopyHelper { return copy; } else if (o.getClass().isArray() && o.getClass().getComponentType().isPrimitive()) { if (o instanceof byte[]) { - byte[] a = (byte[])o; + byte[] a = (byte[]) o; copy = (T) Arrays.copyOf(a, a.length); } else if (o instanceof boolean[]) { - boolean[] a = (boolean[])o; + boolean[] a = (boolean[]) o; copy = (T) Arrays.copyOf(a, a.length); } else if (o instanceof char[]) { - char[] a = (char[])o; + char[] a = (char[]) o; copy = (T) Arrays.copyOf(a, a.length); } else if (o instanceof int[]) { - int[] a = (int[])o; + int[] a = (int[]) o; copy = (T) Arrays.copyOf(a, a.length); } else if (o instanceof long[]) { - long[] a = (long[])o; + long[] a = (long[]) o; copy = (T) Arrays.copyOf(a, a.length); } else if (o instanceof short[]) { - short[] a = (short[])o; + short[] a = (short[]) o; copy = (T) Arrays.copyOf(a, a.length); } else if (o instanceof float[]) { - float[] a = (float[])o; + float[] a = (float[]) o; copy = (T) Arrays.copyOf(a, a.length); } else if (o instanceof double[]) { - double[] a = (double[])o; + double[] a = (double[]) o; copy = (T) Arrays.copyOf(a, a.length); } return copy; @@ -217,20 +231,22 @@ public final class CopyHelper { } /** - * Makes a deep copy of the specified object o using serialization, so the object - * has to be serializable by GemFire. + * Makes a deep copy of the specified object o using serialization, so the object has to be + * serializable by GemFire. * - *

If o is a {@link #isWellKnownImmutableInstance(Object) well known immutable - * instance} then it will be returned without copying it. + *

+ * If o is a {@link #isWellKnownImmutableInstance(Object) well known immutable instance} then it + * will be returned without copying it. * - *

The passed in object is serialized in memory, and then deserialized into - * a new instance, which is returned. If GemFire serialization is implemented - * for the object, it is used; otherwise, java serialization is used. + *

+ * The passed in object is serialized in memory, and then deserialized into a new instance, which + * is returned. If GemFire serialization is implemented for the object, it is used; otherwise, + * java serialization is used. * * @param o the original object to be copied * @return the new instance that is a copy of the original - * @throws CopyException if copying fails because a class could not - * be found or could not be serialized + * @throws CopyException if copying fails because a class could not be found or could not be + * serialized * @see #copy(Object) */ public static T deepCopy(T o) { @@ -252,15 +268,19 @@ public final class CopyHelper { } @SuppressWarnings("unchecked") - private static T doDeepCopy(T o) { + private static T doDeepCopy(T o) { try { HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT); DataSerializer.writeObject(o, hdos); - return (T)DataSerializer.readObject(new DataInputStream(hdos.getInputStream())); + return (T) DataSerializer.readObject(new DataInputStream(hdos.getInputStream())); } catch (ClassNotFoundException ex) { - throw new CopyException(LocalizedStrings.CopyHelper_COPY_FAILED_ON_INSTANCE_OF_0.toLocalizedString(o.getClass()), ex); + throw new CopyException( + LocalizedStrings.CopyHelper_COPY_FAILED_ON_INSTANCE_OF_0.toLocalizedString(o.getClass()), + ex); } catch (IOException ex) { - throw new CopyException(LocalizedStrings.CopyHelper_COPY_FAILED_ON_INSTANCE_OF_0.toLocalizedString(o.getClass()), ex); + throw new CopyException( + LocalizedStrings.CopyHelper_COPY_FAILED_ON_INSTANCE_OF_0.toLocalizedString(o.getClass()), + ex); } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/geode-core/src/main/java/org/apache/geode/DataSerializable.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/org/apache/geode/DataSerializable.java b/geode-core/src/main/java/org/apache/geode/DataSerializable.java index d7c60a5..4c35c31 100644 --- a/geode-core/src/main/java/org/apache/geode/DataSerializable.java +++ b/geode-core/src/main/java/org/apache/geode/DataSerializable.java @@ -1,137 +1,114 @@ /* - * 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 + * 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 + * 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. + * 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.geode; import java.io.*; /** - * An interface for objects whose state can be written/read as - * primitive types and strings ("data"). That is, instead of - * serializing itself to an {@link java.io.ObjectOutputStream}, a - * DataSerializable can serialize itself to a {@link - * DataOutput}. By implementing this interface, objects can be - * serialized faster and in a more compact format than standard Java - * serialization. The {@link DataSerializer} class contains a number - * of static methods that may be helpful to implementations of - * DataSerializable. + * An interface for objects whose state can be written/read as primitive types and strings ("data"). + * That is, instead of serializing itself to an {@link java.io.ObjectOutputStream}, a + * DataSerializable can serialize itself to a {@link DataOutput}. By implementing this + * interface, objects can be serialized faster and in a more compact format than standard Java + * serialization. The {@link DataSerializer} class contains a number of static methods that may be + * helpful to implementations of DataSerializable. * *

* - * When possible, GemFire respects the DataSerializable - * contract to provide optimal object serialization. For instance, if - * a DataSerializable object is - * {@linkplain org.apache.geode.cache.Region#put(Object, Object) placed} into a distributed - * cache region, its toData method will be used to - * serialize it when it is sent to another member of the distributed - * system. + * When possible, GemFire respects the DataSerializable contract to provide optimal + * object serialization. For instance, if a DataSerializable object is + * {@linkplain org.apache.geode.cache.Region#put(Object, Object) placed} into a distributed cache + * region, its toData method will be used to serialize it when it is sent to another + * member of the distributed system. * *

* - * To avoid the overhead of Java reflection, - * DataSerializable classes may register an {@link - * Instantiator} to be used during deserialization. Alternatively, - * classes that implement DataSerializable can provide a - * zero-argument constructor that will be invoked when they are read - * with {@link DataSerializer#readObject}. + * To avoid the overhead of Java reflection, DataSerializable classes may register an + * {@link Instantiator} to be used during deserialization. Alternatively, classes that implement + * DataSerializable can provide a zero-argument constructor that will be invoked when + * they are read with {@link DataSerializer#readObject}. * *

* - * Some classes (especially third-party classes that you may not have - * the source code to) cannot be modified to implement - * DataSerializable. These classes can be data - * serialized by an instance of {@link DataSerializer}. + * Some classes (especially third-party classes that you may not have the source code to) cannot be + * modified to implement DataSerializable. These classes can be data serialized by an + * instance of {@link DataSerializer}. * *

* - * DataSerializable offers improved performance over - * standard Java serialization, but does not offer all of the features - * of standard Java serialization. In particular, data serialization - * does not attempt to maintain referential integrity among the - * objects it is writing or reading. As a result, data serialization - * should not be used with complex object graphs. Attempting to data - * serialize graphs that contain object cycles will result in infinite - * recursion and a {@link StackOverflowError}. Attempting to - * deserialize an object graph that contains multiple reference - * paths to the same object will result in multiple copies of the - * objects that are referred to through multiple paths. + * DataSerializable offers improved performance over standard Java serialization, but + * does not offer all of the features of standard Java serialization. In particular, data + * serialization does not attempt to maintain referential integrity among the objects it is writing + * or reading. As a result, data serialization should not be used with complex object graphs. + * Attempting to data serialize graphs that contain object cycles will result in infinite recursion + * and a {@link StackOverflowError}. Attempting to deserialize an object graph that contains + * multiple reference paths to the same object will result in multiple copies of the objects that + * are referred to through multiple paths. * *

* *

- * + * *
* * @see java.io.Serializable * @see DataSerializer * @see Instantiator * - * @since GemFire 3.5 */ + * @since GemFire 3.5 + */ public interface DataSerializable extends Serializable { /** - * Writes the state of this object as primitive data to the given - * DataOutput. + * Writes the state of this object as primitive data to the given DataOutput. *

- * Since 5.7 it is possible for any method call to the specified - * DataOutput to throw {@link GemFireRethrowable}. - * It should not be caught by user code. - * If it is it must be rethrown. + * Since 5.7 it is possible for any method call to the specified DataOutput to throw + * {@link GemFireRethrowable}. It should not be caught by user code. If it is it + * must be rethrown. * - * @throws IOException - * A problem occurs while writing to out + * @throws IOException A problem occurs while writing to out */ public void toData(DataOutput out) throws IOException; /** - * Reads the state of this object as primitive data from the given - * DataInput. + * Reads the state of this object as primitive data from the given DataInput. * - * @throws IOException - * A problem occurs while reading from in - * @throws ClassNotFoundException - * A class could not be loaded while reading from - * in + * @throws IOException A problem occurs while reading from in + * @throws ClassNotFoundException A class could not be loaded while reading from in */ - public void fromData(DataInput in) - throws IOException, ClassNotFoundException; + public void fromData(DataInput in) throws IOException, ClassNotFoundException; - //////////////////////// Inner Classes //////////////////////// + //////////////////////// Inner Classes //////////////////////// /** - * Replaceable allows an object to write an alternative - * version of itself to a DataOutput. It is similar to - * the writeReplace method of standard Java - * {@linkplain java.io.Serializable serialization}. + * Replaceable allows an object to write an alternative version of itself to a + * DataOutput. It is similar to the writeReplace method of standard Java + * {@linkplain java.io.Serializable serialization}. * *

* - * Note that if a Replaceable is also - * DataSerializable, its toData method - * will not be invoked. Instead, its replacement object will - * be written to the stream using {@link DataSerializer#writeObject(Object, DataOutput)}. + * Note that if a Replaceable is also DataSerializable, its + * toData method will not be invoked. Instead, its replacement object will be + * written to the stream using {@link DataSerializer#writeObject(Object, DataOutput)}. * * @see DataSerializer#writeObject(Object, DataOutput) */ public interface Replaceable { /** - * Replaces this object with another in the "output stream" - * written by {@link DataSerializer#writeObject(Object, DataOutput)}. + * Replaces this object with another in the "output stream" written by + * {@link DataSerializer#writeObject(Object, DataOutput)}. */ public Object replace() throws IOException; }