Skip to content

Commit

Permalink
chore(java): move ignore method into Exception util (#1584)
Browse files Browse the repository at this point in the history
## What does this PR do?

move exception ignore method into Exception util

## Related issues

<!--
Is there any related issue? Please attach here.

- #xxxx0
- #xxxx1
- #xxxx2
-->


## Does this PR introduce any user-facing change?

<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/incubator-fury/issues/new/choose)
describing the need to do so and update the document if necessary.
-->

- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?


## Benchmark

<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
  • Loading branch information
chaokunyang authored Apr 27, 2024
1 parent 91170b5 commit e664615
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
import org.apache.fury.serializer.Serializers;
import org.apache.fury.type.Descriptor;
import org.apache.fury.type.DescriptorGrouper;
import org.apache.fury.util.ExceptionUtils;
import org.apache.fury.util.Preconditions;
import org.apache.fury.util.StringUtils;
import org.apache.fury.util.Utils;
import org.apache.fury.util.record.RecordComponent;
import org.apache.fury.util.record.RecordUtils;

Expand Down Expand Up @@ -174,7 +174,7 @@ protected Expression setFieldValue(Expression bean, Descriptor descriptor, Expre
// Note that the field value shouldn't be an inlined value, otherwise field value read may
// be ignored.
// Add an ignored call here to make expression type to void.
return new Expression.StaticInvoke(Utils.class, "ignore", value);
return new Expression.StaticInvoke(ExceptionUtils.class, "ignore", value);
}
return super.setFieldValue(bean, descriptor, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
import org.apache.fury.resolver.ClassResolver;
import org.apache.fury.resolver.FieldResolver;
import org.apache.fury.resolver.FieldResolver.ClassField;
import org.apache.fury.util.ExceptionUtils;
import org.apache.fury.util.Preconditions;
import org.apache.fury.util.Utils;
import org.apache.fury.util.unsafe._JDKAccess;

/**
Expand Down Expand Up @@ -296,7 +296,7 @@ private StreamClassInfo(Class<?> type) {
_JDKAccess.makeJDKConsumer(lookup, lookup.unreflect(readObjectNoData));
}
} catch (Exception e) {
Utils.ignore(e);
ExceptionUtils.ignore(e);
}
this.writeObjectFunc = writeObjectFunc;
this.readObjectFunc = readObjectFunc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
import org.apache.fury.reflect.ReflectionUtils;
import org.apache.fury.resolver.ClassResolver;
import org.apache.fury.type.Type;
import org.apache.fury.util.ExceptionUtils;
import org.apache.fury.util.GraalvmSupport;
import org.apache.fury.util.Preconditions;
import org.apache.fury.util.Utils;
import org.apache.fury.util.unsafe._JDKAccess;

/** Serialization utils and common serializers. */
Expand Down Expand Up @@ -128,14 +128,14 @@ private static <T> Serializer<T> createSerializer(
CTR_MAP.put(serializerClass, Tuple2.of(SIG1, ctr));
return (Serializer<T>) ctr.invoke(fury, type);
} catch (NoSuchMethodException e) {
Utils.ignore(e);
ExceptionUtils.ignore(e);
}
try {
MethodHandle ctr = lookup.findConstructor(serializerClass, SIG2);
CTR_MAP.put(serializerClass, Tuple2.of(SIG2, ctr));
return (Serializer<T>) ctr.invoke(fury);
} catch (NoSuchMethodException e) {
Utils.ignore(e);
ExceptionUtils.ignore(e);
}
try {
MethodHandle ctr = lookup.findConstructor(serializerClass, SIG3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import org.apache.fury.type.Generics;
import org.apache.fury.type.Type;
import org.apache.fury.type.TypeUtils;
import org.apache.fury.util.ExceptionUtils;
import org.apache.fury.util.Preconditions;
import org.apache.fury.util.Utils;

/**
* A serializer used for cross-language serialization for custom objects.
Expand Down Expand Up @@ -73,7 +73,7 @@ public StructSerializer(Fury fury, Class<T> cls, String typeTag) {
ctr.setAccessible(true);
}
} catch (Exception e) {
Utils.ignore(e);
ExceptionUtils.ignore(e);
}
this.constructor = ctr;
fieldAccessors =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.apache.fury.memory.MemoryBuffer;
import org.apache.fury.memory.Platform;
import org.apache.fury.serializer.Serializer;
import org.apache.fury.util.Utils;
import org.apache.fury.util.ExceptionUtils;

/** Serializer for synchronized Collections and Maps created via Collections. */
@SuppressWarnings({"rawtypes", "unchecked"})
Expand Down Expand Up @@ -203,7 +203,7 @@ public static void registerSerializers(Fury fury) {
fury.registerSerializer(factory.f0, createSerializer(fury, factory));
}
} catch (Throwable e) {
Utils.ignore(e);
ExceptionUtils.ignore(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.apache.fury.memory.MemoryBuffer;
import org.apache.fury.memory.Platform;
import org.apache.fury.serializer.Serializer;
import org.apache.fury.util.ExceptionUtils;
import org.apache.fury.util.Preconditions;
import org.apache.fury.util.Utils;

/** Serializer for unmodifiable Collections and Maps created via Collections. */
@SuppressWarnings({"rawtypes", "unchecked"})
Expand Down Expand Up @@ -201,7 +201,7 @@ public static void registerSerializers(Fury fury) {
fury.registerSerializer(factory.f0, createSerializer(fury, factory));
}
} catch (Throwable e) {
Utils.ignore(e);
ExceptionUtils.ignore(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ public static StackOverflowError trySetStackOverflowErrorMessage(
return null;
}
}

public static void ignore(Object... args) {}
}
5 changes: 1 addition & 4 deletions java/fury-core/src/main/java/org/apache/fury/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@
package org.apache.fury.util;

/** Misc common utils. */
public class Utils {

public static void ignore(Object... args) {}
}
public class Utils {}
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
import org.apache.fury.collection.Tuple2;
import org.apache.fury.memory.Platform;
import org.apache.fury.type.TypeUtils;
import org.apache.fury.util.ExceptionUtils;
import org.apache.fury.util.GraalvmSupport;
import org.apache.fury.util.Preconditions;
import org.apache.fury.util.Utils;
import org.apache.fury.util.function.ToByteFunction;
import org.apache.fury.util.function.ToCharFunction;
import org.apache.fury.util.function.ToFloatFunction;
Expand Down Expand Up @@ -116,7 +116,7 @@ public static <T> T tryMakeFunction(
try {
return makeFunction(lookup, handle, functionInterface);
} catch (Throwable e) {
Utils.ignore(e);
ExceptionUtils.ignore(e);
throw new IllegalStateException();
}
}
Expand Down

0 comments on commit e664615

Please sign in to comment.