This is an automated email from the ASF dual-hosted git repository.

zrhoffman pushed a commit to branch 6.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 3a3e76af8a1c461c8fd2e7ca11a7d2692e47b4ab
Author: Steve Malenfant <[email protected]>
AuthorDate: Tue Aug 31 14:40:46 2021 -0400

    Fix a null pointer exception when delivery service doesn't exist (#6153)
    
    * Fix a null pointer exception when delivery service doesn't exist
    
    * Fixing white spaces
    
    * Fixes tab
    
    * Removing space and adding tabs
    
    Co-authored-by: Steve Malenfant <[email protected]>
    (cherry picked from commit a4334ad4a65d3a43463ad23142241957fc72c581)
---
 .../traffic_router/core/dns/ZoneManager.java         | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git 
a/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/ZoneManager.java
 
b/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/ZoneManager.java
index a040bd6..674b8cf 100644
--- 
a/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/ZoneManager.java
+++ 
b/traffic_router/core/src/main/java/org/apache/traffic_control/traffic_router/core/dns/ZoneManager.java
@@ -701,10 +701,10 @@ public class ZoneManager extends Resolver {
                                                ttl = 
ZoneUtils.getLong(ds.getTtls(), type, 60);
                                        }
                                        switch(type) {
-                                               case "A": 
+                                               case "A":
                                                        list.add(new 
ARecord(name, DClass.IN, ttl, InetAddress.getByName(value)));
                                                        break;
-                                               case "AAAA": 
+                                               case "AAAA":
                                                        list.add(new 
AAAARecord(name, DClass.IN, ttl, InetAddress.getByName(value)));
                                                        break;
                                                case "CNAME":
@@ -741,7 +741,7 @@ public class ZoneManager extends Resolver {
                        // NSRecords will be replaced later if 
tr.isEdgeDNSRouting() is true; we need these to allow stub zones to be signed, 
etc
                        list.add(new NSRecord(name, DClass.IN, 
ZoneUtils.getLong(ttl, "NS", 60), getGlueName(ds, trJo, name, key)));
                        list.add(new ARecord(trName,
-                                       DClass.IN, ZoneUtils.getLong(ttl, "A", 
60), 
+                                       DClass.IN, ZoneUtils.getLong(ttl, "A", 
60),
                                        
InetAddress.getByName(JsonUtils.optString(trJo, IP))));
 
                        String ip6 = trJo.get("ip6").asText();
@@ -866,7 +866,7 @@ public class ZoneManager extends Resolver {
 
        /**
         * Gets trafficRouter.
-        * 
+        *
         * @return the trafficRouter
         */
        public TrafficRouter getTrafficRouter() {
@@ -875,7 +875,7 @@ public class ZoneManager extends Resolver {
 
        /**
         * Attempts to find a {@link Zone} that would contain the specified 
{@link Name}.
-        * 
+        *
         * @param name
         *            the Name to use to attempt to find the Zone
         * @return the Zone to use to resolve the specified Name
@@ -922,7 +922,7 @@ public class ZoneManager extends Resolver {
        /**
         * Creates a dynamic zone that serves a set of A and AAAA records for 
the specified {@link Name}
         * .
-        * 
+        *
         * @param staticZone
         *            The Zone that would normally serve this request
         * @param builder
@@ -940,8 +940,12 @@ public class ZoneManager extends Resolver {
                        if (result != null) {
                                final Zone dynamicZone = 
fillDynamicZone(dynamicZoneCache, staticZone, request, result);
                                track.setResultCode(dynamicZone, 
request.getName(), request.getQueryType());
-                               
builder.deliveryServiceXmlIds(result.getDeliveryService().getId());
-                               return dynamicZone;
+                               if (result.getDeliveryService() == null) {
+                                       builder.deliveryServiceXmlIds(null);
+                               } else {
+                                       
builder.deliveryServiceXmlIds(result.getDeliveryService().getId());
+                               }
+                               return dynamicZone;
                        } else {
                                return null;
                        }

Reply via email to