Skip to content

Commit

Permalink
internal sillyness
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNavaStar committed Aug 25, 2024
1 parent a66c050 commit b5b9e1b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ public ClientAuthHandler newClientAuthHandler() {
return clientAuthHandler.getDeclaredConstructor().newInstance();
}

public byte[] serialize(@NonNull Object packet) throws InsecureException {
public byte[] serialize(@NonNull Object packet) throws IllegalArgumentException {
return serializer.serialize(packet);
}

public Object deserialize(byte @NonNull [] packet) throws InsecureException {
public Object deserialize(byte @NonNull [] packet) throws IllegalArgumentException {
return serializer.deserialize(packet);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> l
packet = connection.getProtocol().deserialize(bytes);
handler.handlePacket(connection, packet);

} catch (InsecureException e) {
} catch (IllegalArgumentException e) {
ProtoLogger.warn("Protocol: " + connection.getProtocol() + " ignoring an " + e.getMessage());
} catch (Exception e) {
if (packet != null) ProtoLogger.error("Protocol: " + connection.getProtocol() + " threw an error when trying to handle: " + packet.getClass() + "!");
Expand All @@ -84,7 +84,7 @@ public Sender send(Object packet) {
buf = Unpooled.buffer();
return sender;

} catch (InsecureException e) {
} catch (IllegalArgumentException e) {
ProtoLogger.error("Protocol: " + connection.getProtocol() + " tried to send an " + e.getMessage());
return new Sender(connection, ctx.newSucceededFuture(), false);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ public void register(Class<?> type) {
recursiveRegister(type, new ArrayList<>());
}

public byte[] serialize(Object object) throws InsecureException {
public byte[] serialize(Object object) throws IllegalArgumentException {
try {
return fury.serialize(object);
} catch (InsecureException e) {
throw new InsecureException("unregistered object: " + object.getClass().getName());
throw new IllegalArgumentException("unregistered object: " + object.getClass().getName());
}
}

public Object deserialize(byte[] bytes) throws InsecureException {
public Object deserialize(byte[] bytes) throws IllegalArgumentException {
try {
return fury.deserialize(bytes);
} catch (InsecureException e) {
String packet = e.getMessage().split(" is not registered")[0].replace("class ", "");
throw new InsecureException("unregistered object: " + packet);
throw new IllegalArgumentException("unregistered object: " + packet);
}
}
}

0 comments on commit b5b9e1b

Please sign in to comment.