From 05b18045dcb8197db7ba9f574f8e11888df8a4e1 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Sat, 21 Dec 2024 06:40:00 -0800 Subject: [PATCH] add comments --- .../elasticsearch/hdfs/patch/ShutdownHookManagerPatcher.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/repository-hdfs/hadoop-client-api/src/patcher/java/org/elasticsearch/hdfs/patch/ShutdownHookManagerPatcher.java b/plugins/repository-hdfs/hadoop-client-api/src/patcher/java/org/elasticsearch/hdfs/patch/ShutdownHookManagerPatcher.java index abb6a42f4d8ad..f5370b977c8c9 100644 --- a/plugins/repository-hdfs/hadoop-client-api/src/patcher/java/org/elasticsearch/hdfs/patch/ShutdownHookManagerPatcher.java +++ b/plugins/repository-hdfs/hadoop-client-api/src/patcher/java/org/elasticsearch/hdfs/patch/ShutdownHookManagerPatcher.java @@ -32,14 +32,17 @@ class ShutdownHookManagerPatcher extends ClassVisitor { public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { MethodVisitor mv = super.visitMethod(access, name, descriptor, signature, exceptions); if (VOID_METHODS.contains(name)) { + // make void methods noops return new MethodReplacement(mv, () -> { mv.visitInsn(Opcodes.RETURN); }); } else if (BOOLEAN_METHODS.contains(name)) { + // make boolean methods always return false return new MethodReplacement(mv, () -> { mv.visitInsn(Opcodes.ICONST_0); mv.visitInsn(Opcodes.IRETURN); }); } else if (name.equals("")) { return new MethodReplacement(mv, () -> { + // just initialize the two statics, don't actually get runtime to add shutdown hook var timeUnitType = Type.getType(TimeUnit.class); var executorServiceType = Type.getType(ExecutorService.class); mv.visitFieldInsn(Opcodes.GETSTATIC, timeUnitType.getInternalName(), "SECONDS", timeUnitType.getDescriptor());