1- // Copyright (c) 2020, 2023 , Oracle and/or its affiliates.
1+ // Copyright (c) 2020, 2024 , Oracle and/or its affiliates.
22// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
33
44package oracle .kubernetes .operator ;
@@ -154,7 +154,7 @@ private void addOperatorEventList(CoreV1EventList list) {
154154 private void addPod (V1Pod pod ) {
155155 String domainUid = PodHelper .getPodDomainUid (pod );
156156 String serverName = PodHelper .getPodServerName (pod );
157- DomainPresenceInfo info = getExistingDomainPresenceInfo (domainUid );
157+ DomainPresenceInfo info = getOrComputeDomainPresenceInfo (domainUid );
158158 Optional .ofNullable (info ).ifPresent (i -> i .addServerNameFromPodList (serverName ));
159159
160160 if (domainUid != null && serverName != null ) {
@@ -173,10 +173,6 @@ private DomainPresenceInfo getOrComputeDomainPresenceInfo(String domainUid) {
173173 return getDomainPresenceInfoMap ().computeIfAbsent (domainUid , k -> new DomainPresenceInfo (namespace , domainUid ));
174174 }
175175
176- private DomainPresenceInfo getExistingDomainPresenceInfo (String domainUid ) {
177- return getDomainPresenceInfoMap ().get (domainUid );
178- }
179-
180176 private Map <String , DomainPresenceInfo > getDomainPresenceInfoMap () {
181177 return processor .getDomainPresenceInfoMap ().computeIfAbsent (namespace , k -> new ConcurrentHashMap <>());
182178 }
@@ -192,7 +188,7 @@ private void addServiceList(V1ServiceList list) {
192188 private void addService (V1Service service ) {
193189 String domainUid = ServiceHelper .getServiceDomainUid (service );
194190 if (domainUid != null ) {
195- ServiceHelper .addToPresence (getExistingDomainPresenceInfo (domainUid ), service );
191+ ServiceHelper .addToPresence (getOrComputeDomainPresenceInfo (domainUid ), service );
196192 }
197193 }
198194
@@ -203,7 +199,7 @@ private void addPodDisruptionBudgetList(V1PodDisruptionBudgetList list) {
203199 private void addPodDisruptionBudget (V1PodDisruptionBudget pdb ) {
204200 String domainUid = PodDisruptionBudgetHelper .getDomainUid (pdb );
205201 if (domainUid != null ) {
206- PodDisruptionBudgetHelper .addToPresence (getExistingDomainPresenceInfo (domainUid ), pdb );
202+ PodDisruptionBudgetHelper .addToPresence (getOrComputeDomainPresenceInfo (domainUid ), pdb );
207203 }
208204 }
209205
@@ -231,7 +227,8 @@ private void addDomain(DomainResource domain) {
231227 DomainPresenceInfo cachedInfo = getDomainPresenceInfoMap ().get (domain .getDomainUid ());
232228 if (domain .getStatus () == null ) {
233229 newDomainNames .add (domain .getDomainUid ());
234- } else if (cachedInfo != null && domain .isGenerationChanged (cachedInfo .getDomain ())) {
230+ } else if (cachedInfo != null && cachedInfo .getDomain () != null
231+ && domain .isGenerationChanged (cachedInfo .getDomain ())) {
235232 modifiedDomainNames .add (domain .getDomainUid ());
236233 }
237234 getOrComputeDomainPresenceInfo (domain .getDomainUid ()).setDomain (domain );
0 commit comments