diff --git a/core/src/main/java/org/jruby/util/io/EncodingUtils.java b/core/src/main/java/org/jruby/util/io/EncodingUtils.java index d8e25a2cf8c3..476fc0eae1fd 100644 --- a/core/src/main/java/org/jruby/util/io/EncodingUtils.java +++ b/core/src/main/java/org/jruby/util/io/EncodingUtils.java @@ -262,11 +262,13 @@ public static void extractModeEncoding(ThreadContext context, v = hashARef(runtime, options, "perm"); if (!v.isNil()) { - if (vperm(vmodeAndVperm_p) != null) { - if (!vperm(vmodeAndVperm_p).isNil()) throw runtime.newArgumentError("perm specified twice"); - - vperm(vmodeAndVperm_p, v); + if (vperm(vmodeAndVperm_p) != null && !vperm(vmodeAndVperm_p).isNil()) { + throw runtime.newArgumentError("perm specified twice"); } + + vperm(vmodeAndVperm_p, v); + } else { + /* perm no use, just ignore */ } IRubyObject extraFlags = hashARef(runtime, options, "flags");