Skip to content

Commit

Permalink
Merge pull request #7099 from Viii3/FISH-10146-Nullpointer-Instance
Browse files Browse the repository at this point in the history
FISH-10146 FISH-9875 Deployment Group Nullpointer
  • Loading branch information
breakponchito authored Dec 4, 2024
2 parents 5633806 + 375b756 commit 26188ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018-2023] Payara Foundation and/or affiliates
// Portions Copyright [2018-2024] Payara Foundation and/or affiliates

package org.glassfish.config.support;

Expand All @@ -48,6 +48,7 @@
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
Expand Down Expand Up @@ -91,7 +92,7 @@ private DomainXmlPreParserException(String s) {
private List<String> configNames = new LinkedList<>();
private Map<String, String> mapServerConfig = new HashMap<>();
private ClusterData cluster;
private DeploymentGroupData deploymentGroup;
private DeploymentGroupData deploymentGroup; // Refers to the FIRST deployment group for this instance.
private String instanceName;
private String serverConfigRef;
private boolean valid = false;
Expand Down Expand Up @@ -129,14 +130,6 @@ final String getClusterName() {
return cluster.name;
}


final String getDeploymentGroupName() {
if(!validDG) {
return null;
}
return deploymentGroup.name;
}

final List<String> getServerNames() {
if(!valid) {
return null;
Expand All @@ -146,9 +139,14 @@ final List<String> getServerNames() {

final List<String> getDGServerNames() {
if(!validDG) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
return deploymentGroup.dgServerRefs;

return deploymentGroups
.stream()
.filter(groupData -> groupData.dgServerRefs.contains(instanceName))
.flatMap(groupData -> groupData.dgServerRefs.stream())
.collect(Collectors.toList());
}

public Map<String, String> getMapServerConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018-2023] Payara Foundation and/or affiliates
// Portions Copyright [2018-2024] Payara Foundation and/or affiliates

package org.glassfish.config.support;

Expand Down Expand Up @@ -98,10 +98,6 @@ final boolean filterOut() throws XMLStreamException {
if (elementName.equals(CLUSTER)){
return handleCluster(reader);
}

if (elementName.equals(DEPLOYMENT_GROUP)){
return handleDeploymentGroup(reader);
}

// keep everything else
return false;
Expand Down Expand Up @@ -160,19 +156,6 @@ private boolean handleCluster(XMLStreamReader reader) {
return !(StringUtils.ok(myCluster) && myCluster.equals(name));
}

/**
* Note that dxpp.getClusterName() will definitely return null
* for stand-alone instances. This is normal.
*
* @return true if we want to filter out this DEPLOYMENT GROUP element
*/
private boolean handleDeploymentGroup(XMLStreamReader reader) {
String name = reader.getAttributeValue(null, NAME);
String myDG = dxpp.getDeploymentGroupName();

return !(StringUtils.ok(myDG) && myDG.equals(name));
}

private final DomainXmlPreParser dxpp;
private final String instanceName;
}

0 comments on commit 26188ec

Please sign in to comment.