forked from GTNewHorizons/Hodgepodge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move NettyPatcher fix to Hodgepodge (GTNewHorizons#265)
* translate NettyPatch to mixins
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/com/mitchej123/hodgepodge/mixins/early/netty/MixinBootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.mitchej123.hodgepodge.mixins.early.netty; | ||
|
||
import java.net.InetAddress; | ||
import java.net.SocketAddress; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture; | ||
|
||
import io.netty.bootstrap.Bootstrap; | ||
import io.netty.channel.ChannelFuture; | ||
|
||
@Mixin(Bootstrap.class) | ||
public class MixinBootstrap { | ||
|
||
@Inject( | ||
method = "checkAddress", | ||
remap = false, | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Ljava/net/InetAddress;getHostAddress()Ljava/lang/String;", | ||
shift = At.Shift.BEFORE), | ||
locals = LocalCapture.CAPTURE_FAILSOFT, | ||
cancellable = true) | ||
private void hodgpodge$fixNPE(SocketAddress remoteAddress, CallbackInfoReturnable<ChannelFuture> cir, | ||
InetAddress address) { | ||
if (address == null) { | ||
cir.setReturnValue(null); | ||
} | ||
} | ||
} |