Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
petrov-mg committed Mar 31, 2024
1 parent 965fb22 commit 5f0196a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public byte[] marshal(@Nullable Object obj, boolean failIfUnregistered) throws B
BinaryContext oldCtx = pushContext(ctx);

try {
return (T)new BinaryReaderExImpl(ctx, in, ldr, hnds, true).deserialize();
return (T)new BinaryReaderExImpl(ctx, in, ldr, null, true).deserialize();
}
finally {
popContext(oldCtx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,16 +573,14 @@ <T> T readObject(BinaryInputStream in, boolean keepBinary, Class<T> clazz) {
if (keepBinary)
return (T)marsh.unmarshal(in);
else {
BinaryReaderHandles hnds = new BinaryReaderHandles();

return (T)unwrapBinary(marsh.deserialize(in, hnds), hnds, clazz);
return (T)unwrapBinary(marsh.deserialize(in, new BinaryReaderHandles()), clazz);
}
}

/**
* Unwrap binary object.
*/
private Object unwrapBinary(Object obj, BinaryReaderHandles hnds, Class<?> clazz) {
private Object unwrapBinary(Object obj, Class<?> clazz) {
if (obj instanceof BinaryObjectImpl) {
BinaryObjectImpl obj0 = (BinaryObjectImpl)obj;

Expand All @@ -591,43 +589,43 @@ private Object unwrapBinary(Object obj, BinaryReaderHandles hnds, Class<?> clazz
else if (obj instanceof BinaryObject)
return ((BinaryObject)obj).deserialize();
else if (BinaryUtils.knownCollection(obj))
return unwrapCollection((Collection<Object>)obj, hnds);
return unwrapCollection((Collection<Object>)obj);
else if (BinaryUtils.knownMap(obj))
return unwrapMap((Map<Object, Object>)obj, hnds);
return unwrapMap((Map<Object, Object>)obj);
else if (obj instanceof Object[])
return unwrapArray((Object[])obj, hnds, clazz);
return unwrapArray((Object[])obj, clazz);
else
return obj;
}

/**
* Unwrap collection with binary objects.
*/
private Collection<Object> unwrapCollection(Collection<Object> col, BinaryReaderHandles hnds) {
private Collection<Object> unwrapCollection(Collection<Object> col) {
Collection<Object> col0 = BinaryUtils.newKnownCollection(col);

for (Object obj0 : col)
col0.add(unwrapBinary(obj0, hnds, null));
col0.add(unwrapBinary(obj0, null));

return (col0 instanceof MutableSingletonList) ? U.convertToSingletonList(col0) : col0;
}

/**
* Unwrap map with binary objects.
*/
private Map<Object, Object> unwrapMap(Map<Object, Object> map, BinaryReaderHandles hnds) {
private Map<Object, Object> unwrapMap(Map<Object, Object> map) {
Map<Object, Object> map0 = BinaryUtils.newMap(map);

for (Map.Entry<Object, Object> e : map.entrySet())
map0.put(unwrapBinary(e.getKey(), hnds, null), unwrapBinary(e.getValue(), hnds, null));
map0.put(unwrapBinary(e.getKey(), null), unwrapBinary(e.getValue(), null));

return map0;
}

/**
* Unwrap array with binary objects.
*/
private Object[] unwrapArray(Object[] arr, BinaryReaderHandles hnds, Class<?> arrayClass) {
private Object[] unwrapArray(Object[] arr, Class<?> arrayClass) {
if (BinaryUtils.knownArray(arr))
return arr;

Expand All @@ -638,7 +636,7 @@ private Object[] unwrapArray(Object[] arr, BinaryReaderHandles hnds, Class<?> ar
Object[] res = (Object[])Array.newInstance(componentType, arr.length);

for (int i = 0; i < arr.length; i++)
res[i] = unwrapBinary(arr[i], hnds, null);
res[i] = unwrapBinary(arr[i], null);

return res;
}
Expand Down

0 comments on commit 5f0196a

Please sign in to comment.