Skip to content

Commit

Permalink
Warning about use when references are enabled.
Browse files Browse the repository at this point in the history
closes #286
  • Loading branch information
NathanSweet committed Feb 18, 2015
1 parent de87b84 commit 7e67a1f
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

package com.esotericsoftware.kryo.serializers;

import com.esotericsoftware.kryo.Kryo;
Expand All @@ -31,6 +31,9 @@
/** Serializes objects using direct field assignment, with limited support for forward and backward compatibility. Fields can be
* added or removed without invalidating previously serialized bytes. Note that changing the type of a field is not supported.
* <p>
* Removing fields when {@link Kryo#setReferences(boolean) references} are enabled can cause compatibility issues. See <a
* href="https://github.com/EsotericSoftware/kryo/issues/286#issuecomment-74870545">here</a>.
* <p>
* There is additional overhead compared to {@link FieldSerializer}. A header is output the first time an object of a given type
* is serialized. The header consists of an int for the number of fields, then a String for each field name. Also, to support
* skipping the bytes for a field that no longer exists, for each field value an int is written that is the length of the value in
Expand Down Expand Up @@ -94,9 +97,9 @@ public T read (Kryo kryo, Input input, Class<T> type) {
boolean hasGenerics = getGenerics() != null;
for (int i = 0, n = fields.length; i < n; i++) {
CachedField cachedField = fields[i];
if(cachedField != null && hasGenerics) {
// Generic type used to instantiate this field could have
// been changed in the meantime. Therefore take the most
if (cachedField != null && hasGenerics) {
// Generic type used to instantiate this field could have
// been changed in the meantime. Therefore take the most
// up-to-date definition of a field
cachedField = getField(cachedField.field.getName());
}
Expand All @@ -110,4 +113,4 @@ public T read (Kryo kryo, Input input, Class<T> type) {
}
return object;
}
}
}

0 comments on commit 7e67a1f

Please sign in to comment.