Java create PTR records sets StackOverflow Exception
Hello I have some java code that creates A records and PTR records for a Private Hosted Zone.
I have no issues with the A records, but then the Java tries to create more that 9 PTR records and it fails.
Code is: ` private void fillPtrRecords(PrivateHostedZone zone,String zoneName, String cidr, int low, int high) {
String[] parts = cidr.split("/");
String ip = parts[0];
String[] octets = ip.split("\\.");
if(low>high) {
first_record = low;
last_record = high;
}else {
first_record = 1;
last_record = 10;
}
//int i = first_record;
PTRrecords = new ArrayList<CfnRecordSet>(); //just to hold them and dont make java crazy
for(int i=first_record; i <= last_record; i++) {
String ip1 = octets[0]+"."+octets[1]+"."+octets[2]+"."+Integer.toString(i);
String name = "PTR"+ip1;
String rev_name = Integer.toString(i)+"."+octets[2]+"."+octets[1]+"."+octets[0]+".in-addr.arpa.";
System.out.print("OCT0: "+octets[0]+" OCT1: "+octets[1]+" OCT2: "+octets[2]+" OCT3: "+Integer.toString(i)+"\n");
System.out.print("REV_NAME: "+rev_name+"\n");
System.out.print("IP: "+ip1+"\n");
CfnRecordSetProps rec_props = CfnRecordSetProps.builder()
.withName(rev_name+zone.getZoneName()+".")
.withType("PTR")
.withResourceRecords(Arrays.asList(ip1))
.withHostedZoneName(zoneName+".")
//.withHostedZoneId(zone.getHostedZoneId())
.withTtl("340")
.build();
CfnRecordSet rec = new CfnRecordSet(this,name,rec_props);
PTRrecords.add(rec);
System.out.print(rec.toString()+"\n");
}
}`
Exception is:
CfnRecordSet [StackZoneP1-2/PTR192.168.0.9]
OCT0: 192 OCT1: 168 OCT2: 0 OCT3: 10
REV_NAME: 10.0.168.192.in-addr.arpa.
IP: 192.168.0.10
CfnRecordSet [StackZoneP1-2/PTR192.168.0.10]
[WARNING]
java.lang.NullPointerException
at software.amazon.jsii.JsiiRuntime.requestResponse (JsiiRuntime.java:89)
at software.amazon.jsii.JsiiRuntime.processCallbackResponse (JsiiRuntime.java:163)
at software.amazon.jsii.JsiiRuntime.requestResponse (JsiiRuntime.java:95)
at software.amazon.jsii.JsiiRuntime.processCallbackResponse (JsiiRuntime.java:163)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 43.612 s
[INFO] Finished at: 2019-03-26T10:48:03-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project my_stack_tgw: An exception occured while executing the Java class. null: NullPointerException -> [Help 1]
[ERROR]
I have done a lot of testing and I think there is something wrong on the underlying code because it seems to be spawned based on the number of records. Also if you try it with .withHostedZoneId(zone.getHostedZoneId()) the exception happens sooner.
Hi @evildani, I apologize for the late reply. Are you still experiencing this issue?
Closing this issue since there hasn't been activity on it in a while. Feel free to reopen if you are still experiencing this issue.