Skip to content

Commit 63e536a

Browse files
committed
[refactor] simplify - extra checks not needed
1 parent 19e0b1b commit 63e536a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/java/org/jruby/ext/openssl/PKeyEC.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public IRubyObject initialize(final ThreadContext context, final IRubyObject[] a
258258
final RubyString str = readInitArg(context, arg);
259259
final String strJava = str.toString();
260260

261-
if (!strJava.isEmpty() && isCurveName(strJava)) {
261+
if (isCurveName(strJava)) {
262262
this.curveName = strJava;
263263
return this;
264264
}
@@ -349,8 +349,9 @@ else if ( key instanceof ECPublicKey ) {
349349
private void setCurveNameFromPublicKeyIfNeeded() {
350350
if (curveName == null && publicKey != null) {
351351
final String oid = getCurveNameObjectIdFromKey(getRuntime(), publicKey);
352-
if (isCurveName(oid)) {
353-
this.curveName = getCurveName(new ASN1ObjectIdentifier(oid));
352+
final Optional<ASN1ObjectIdentifier> curveId = getCurveOID(oid);
353+
if (curveId.isPresent()) {
354+
this.curveName = getCurveName(curveId.get());
354355
}
355356
}
356357
}

0 commit comments

Comments
 (0)