Skip to content

MirroredTypeException Fix #2460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apikey-config/src/main/resources/config/apikey.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion audit-config/src/main/resources/config/audit.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
"default" : true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,3 @@
*/
boolean externalized() default ConfigSchema.DEFAULT_BOOLEAN;
}



Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,3 @@
*/
Format format() default Format.int32;
}


Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.type.MirroredTypeException;
import java.lang.annotation.Annotation;
import java.util.LinkedHashMap;
import java.util.Optional;
Expand Down Expand Up @@ -165,7 +166,13 @@ private static Optional<LinkedHashMap<String, Object>> getObjectPropertyMetadata
* @return A LinkedHashMap containing the metadata.
*/
private static LinkedHashMap<String, Object> parseArrayMetadata(final ArrayField field, final ProcessingEnvironment processingEnvironment) {
final var itemElement = ReflectionUtils.safeGetElement(field.items().getCanonicalName(), processingEnvironment);
String canonicalName;
try {
canonicalName = field.items().getCanonicalName();
} catch (MirroredTypeException e) {
canonicalName = e.getTypeMirrors().get(0).toString();
}
final var itemElement = ReflectionUtils.safeGetElement(canonicalName, processingEnvironment);
final var itemMetadata = new LinkedHashMap<String, Object>();
gatherObjectSchemaData(itemElement, itemMetadata, processingEnvironment);

Expand Down Expand Up @@ -257,7 +264,13 @@ private static LinkedHashMap<String, Object> parseStringMetadata(final StringFie
* @return A LinkedHashMap containing the metadata.
*/
private static LinkedHashMap<String, Object> parseObjectMetadata(final ObjectField field, final ProcessingEnvironment processingEnvironment) {
final var refElement = ReflectionUtils.safeGetElement(field.ref().getCanonicalName(), processingEnvironment);
String canonicalName;
try {
canonicalName = field.ref().getCanonicalName();
} catch (MirroredTypeException e) {
canonicalName = e.getTypeMirrors().get(0).toString();
}
final var refElement = ReflectionUtils.safeGetElement(canonicalName, processingEnvironment);
final var refMetadata = new LinkedHashMap<String, Object>();
gatherObjectSchemaData(refElement, refMetadata, processingEnvironment);
final var metadata = new LinkedHashMap<String, Object>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@
*/
boolean externalized() default ConfigSchema.DEFAULT_BOOLEAN;
}


Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,3 @@
*/
Format format() default Format.float32;
}

Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,3 @@
*/
Class<?>[] oneOf() default {};
}


Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,3 @@
*/
Format format() default Format.none;
}


Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,3 @@ private void addCommentsToNode(final Mark start, final Mark end, final String de
}

}

Original file line number Diff line number Diff line change
@@ -1 +1 @@
com.networknt.config.schema.ConfigAnnotationParser
com.networknt.config.schema.ConfigAnnotationParser
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,4 @@ public void writeYamlSchemaToFile() throws IOException {
assertTrue(Arrays.equals(Files.readAllBytes(file1.toPath()), Files.readAllBytes(file2.toPath())));
}

}
}
2 changes: 1 addition & 1 deletion config/src/test/resources/config/apikey-compare.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
"description" : "If API key hash is enabled. The API key will be hashed with PBKDF2WithHmacSHA1 before it is\nstored in the config file. It is more secure than put the encrypted key into the config file.\nThe default value is false. If you want to enable it, you need to use the following repo\nhttps://github.com/networknt/light-hash command line tool to hash the clear text key."
}
}
}
}
2 changes: 1 addition & 1 deletion config/src/test/resources/config/apikey-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
"description" : "If API key hash is enabled. The API key will be hashed with PBKDF2WithHmacSHA1 before it is\nstored in the config file. It is more secure than put the encrypted key into the config file.\nThe default value is false. If you want to enable it, you need to use the following repo\nhttps://github.com/networknt/light-hash command line tool to hash the clear text key."
}
}
}
}