mirror of
https://github.com/google/nomulus
synced 2026-05-13 11:21:46 +00:00
Fix generics in EppXmlTransformer.unmarshal to not be only on the return type.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=124914271
This commit is contained in:
@@ -56,7 +56,7 @@ public final class EppController {
|
||||
public byte[] handleEppCommand(SessionMetadata sessionMetadata, byte[] inputXmlBytes) {
|
||||
Trid trid = null;
|
||||
try {
|
||||
EppInput eppInput = unmarshal(inputXmlBytes);
|
||||
EppInput eppInput = unmarshal(EppInput.class, inputXmlBytes);
|
||||
trid = Trid.create(eppInput.getCommandWrapper().getClTrid());
|
||||
ImmutableList<String> targetIds = eppInput.getTargetIds();
|
||||
metrics.setCommandName(eppInput.getCommandName());
|
||||
|
||||
@@ -76,9 +76,15 @@ public class EppXmlTransformer {
|
||||
OUTPUT_TRANSFORMER.validate(xml);
|
||||
}
|
||||
|
||||
public static <T> T unmarshal(byte[] bytes) throws EppException {
|
||||
/**
|
||||
* Unmarshal bytes into Epp classes.
|
||||
*
|
||||
* @param clazz type to return, specified as a param to enforce typesafe generics
|
||||
* @see "http://errorprone.info/bugpattern/TypeParameterUnusedInFormals"
|
||||
*/
|
||||
public static <T> T unmarshal(Class<T> clazz, byte[] bytes) throws EppException {
|
||||
try {
|
||||
return INPUT_TRANSFORMER.unmarshal(new ByteArrayInputStream(bytes));
|
||||
return INPUT_TRANSFORMER.unmarshal(clazz, new ByteArrayInputStream(bytes));
|
||||
} catch (XmlException e) {
|
||||
// If this XmlException is wrapping a known type find it. If not, it's a syntax error.
|
||||
FluentIterable<Throwable> causalChain = FluentIterable.from(Throwables.getCausalChain(e));
|
||||
|
||||
@@ -87,7 +87,7 @@ public class DomainApplicationInfoFlow extends BaseDomainInfoFlow<DomainApplicat
|
||||
if (includeMarks) {
|
||||
for (EncodedSignedMark encodedMark : existingResource.getEncodedSignedMarks()) {
|
||||
try {
|
||||
marksBuilder.add(((SignedMark) unmarshal(encodedMark.getBytes())).getMark());
|
||||
marksBuilder.add(unmarshal(SignedMark.class, encodedMark.getBytes()).getMark());
|
||||
} catch (EppException e) {
|
||||
// This is a serious error; don't let the benign EppException propagate.
|
||||
throw new IllegalStateException("Could not decode a stored encoded signed mark");
|
||||
|
||||
@@ -497,7 +497,7 @@ public class DomainFlowUtils {
|
||||
|
||||
SignedMark signedMark;
|
||||
try {
|
||||
signedMark = unmarshal(signedMarkData);
|
||||
signedMark = unmarshal(SignedMark.class, signedMarkData);
|
||||
} catch (EppException e) {
|
||||
throw new SignedMarkParsingErrorException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user