exceptionfactory commented on code in PR #6703:
URL: https://github.com/apache/nifi/pull/6703#discussion_r1035256497
##########
nifi-nar-bundles/nifi-asn1-bundle/nifi-asn1-services/src/main/java/org/apache/nifi/jasn1/JASN1Reader.java:
##########
@@ -219,8 +236,55 @@ private void compileAsnToClass(String... asnFilePaths) {
asnCompilerArguments.add("-o");
asnCompilerArguments.add(asnOutDir.toString());
+ HashMap<String, AsnModule> modulesByName = new HashMap<>();
+
+ Exception parseException = null;
+ for (String asn1File : asnFilePaths) {
+ logger.info("Parsing " + asn1File);
+ try {
+ AsnModel model = getJavaModelFromAsn1File(asn1File);
+ modulesByName.putAll(model.modulesByName);
+ } catch (FileNotFoundException e) {
+ logger.error("Couldn't find " + asn1File, e);
+ parseException = e;
+ } catch (TokenStreamException | RecognitionException e) {
+ logger.error("Error while parsing " + asn1File, e);
+ parseException = e;
+ } catch (Exception e) {
+ logger.error("Couldn't parse " + asn1File, e);
+ parseException = e;
+ }
+ }
+
+ if (parseException != null) {
+ throw new ProcessException("Couldn't parse asn files.",
parseException);
+ }
+
try {
-
com.beanit.asn1bean.compiler.Compiler.main(asnCompilerArguments.toArray(new
String[0]));
+ Constructor<BerClassWriter> berClassWriterConstructor =
BerClassWriter.class.getDeclaredConstructor(
+ HashMap.class,
+ String.class,
+ String.class,
+ Boolean.TYPE,
+ Boolean.TYPE,
+ Boolean.TYPE
+ );
+
+ berClassWriterConstructor.setAccessible(true);
Review Comment:
Looks like a good solution, thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]