Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISH-10146 FISH-9875 Deployment Group Nullpointer #7099

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}