On Thu, 3 Nov 2022 14:26:52 GMT, Matthias Baesken <[email protected]> wrote:
>> This change adds constructors (String,Throwable) and (Throwable) to
>> InvalidParameterException and uses them at a few places in the jdk coding.
>
> Matthias Baesken has updated the pull request incrementally with one
> additional commit since the last revision:
>
> Adjust javadoc of the added InvalidParameterException constructors
Please also update test/jdk/java/security/Exceptions/ChainingConstructors.java
and add a new test for these constructors.
src/java.base/share/classes/java/security/InvalidParameterException.java line
64:
> 62: /**
> 63: * Constructs an {@code InvalidParameterException} with the
> 64: * specified detail message and cause. A detail message is a {@code
> String} that describes
Keep these lines within 80 character width to be consistent with the rest of
the file.
src/java.base/share/classes/java/security/InvalidParameterException.java line
78:
> 76: * unknown.)
> 77: *
> 78: * @since 20
Nit: align "20" with text (add a space) to be consistent with other ctor.
src/java.base/share/classes/java/security/InvalidParameterException.java line
85:
> 83:
> 84: /**
> 85: * Constructs an {@code InvalidParameterException} with the specified
> cause and a detail
Keep these lines within 80 character width to be consistent with the rest of
the file.
src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyGenerator.java
line 338:
> 336: newSignificantKeySize = checkKeySize(mechanism, keySize,
> range);
> 337: } catch (InvalidAlgorithmParameterException iape) {
> 338: throw new InvalidParameterException("Invalid algorithm
> parameter", iape);
I would change this to `throw new InvalidParameterException(iape)`. The detail
message of the cause is more useful in this case.
src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java
line 154:
> 152: checkKeySize(keySize, null);
> 153: } catch (InvalidAlgorithmParameterException e) {
> 154: throw new InvalidParameterException(e.getMessage(), e);
Here too I would change this to `throw new InvalidParameterException(e)` since
the detail message of the cause will be used, the first parameter doesn't add
any value.
test/jdk/sun/security/tools/keytool/fakegen/java.base/sun/security/rsa/RSAKeyPairGenerator.java
line 60:
> 58: RSAKeyGenParameterSpec.F4), random);
> 59: } catch (InvalidAlgorithmParameterException iape) {
> 60: throw new InvalidParameterException(iape.getMessage(), iape);
Use the one-arg ctor to make this consistent with the code above:
[src/java.base/share/classes/sun/security/rsa/RSAKeyPairGenerator.java](https://github.com/openjdk/jdk/pull/10966/files#diff-4eaff4fafb2999bb74081347365803821458dc8ea618808474a948a4dc7d9b75)
-------------
Changes requested by mullan (Reviewer).
PR: https://git.openjdk.org/jdk/pull/10966