Skip to content

Commit 00b7246

Browse files
authored
Merge pull request #25565 from dmatej/hostnames
Fixed bug of 2011 - hostname was resolved as path
2 parents d929a89 + bc632dd commit 00b7246

File tree

2 files changed

+11
-43
lines changed

2 files changed

+11
-43
lines changed

nucleus/common/common-util/src/main/java/com/sun/enterprise/universal/glassfish/GFLauncherUtils.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
package com.sun.enterprise.universal.glassfish;
1919

2020
import com.sun.enterprise.universal.io.SmartFile;
21-
import com.sun.enterprise.util.net.NetUtils;
2221

2322
import java.io.File;
2423
import java.io.IOException;
2524
import java.net.URISyntaxException;
26-
import java.net.UnknownHostException;
2725
import java.util.ArrayList;
2826
import java.util.List;
2927
import java.util.Locale;
@@ -77,20 +75,6 @@ public static boolean isWindows() {
7775
return false;
7876
}
7977

80-
/**
81-
* This method returns the fully qualified name of the host. If
82-
* the name can't be resolved (on windows if there isn't a domain specified), just
83-
* host name is returned
84-
*
85-
* @deprecated
86-
* @return
87-
* @throws UnknownHostException so it can be handled on a case by case basis
88-
*/
89-
@Deprecated
90-
public static String getCanonicalHostName() throws UnknownHostException {
91-
return NetUtils.getCanonicalHostName();
92-
}
93-
9478
public static String replace(String s, String token, String replace) {
9579
if (s == null || s.isEmpty() || token == null || token.isEmpty()) {
9680
return s;

nucleus/common/common-util/src/main/java/org/glassfish/server/ServerEnvironmentImpl.java

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
/**
4040
* Defines various global configuration for the running {@code GlassFish} instance.
41-
*
4241
* <p>
4342
* This primarily replaces all the system variables in V2.
4443
*
@@ -111,60 +110,45 @@ public ServerEnvironmentImpl(File root) {
111110
@PostConstruct
112111
public void postConstruct() {
113112

114-
// todo : dochez : this will need to be reworked...
115113
String installRoot = startupContext.getArguments().getProperty(INSTALL_ROOT.getPropertyName());
116114
if (installRoot == null) {
117115
// During unit testing, we find an empty StartupContext.
118116
// Let's first see if the installRoot system property is set in the client VM. If not
119117
// to be consistent with earlier code (i.e., code that relied on StartupContext.getRootDirectory()),
120118
// I am setting user.dir as installRoot.
121-
if (System.getProperty(INSTALL_ROOT.getSystemPropertyName()) != null) {
122-
installRoot = System.getProperty(INSTALL_ROOT.getSystemPropertyName());
123-
} else {
119+
if (System.getProperty(INSTALL_ROOT.getSystemPropertyName()) == null) {
120+
// current directory
124121
installRoot = System.getProperty("user.dir");
122+
} else {
123+
installRoot = System.getProperty(INSTALL_ROOT.getSystemPropertyName());
125124
}
126125
}
127126
asenv = new ASenvPropertyReader(new File(installRoot));
128127

129128
// Default
130129
if (this.root == null) {
131130
String envVar = System.getProperty(INSTANCE_ROOT.getSystemPropertyName());
132-
if (envVar!=null) {
131+
if (envVar != null) {
133132
root = new File(envVar);
134133
} else {
135134
String instanceRoot = startupContext.getArguments().getProperty(INSTANCE_ROOT.getPropertyName());
136135
if (instanceRoot == null) {
137-
// In client container, instanceRoot is not set. It is a different question altogether as to why
138-
// an object called ServerEnvironmentImpl is at all active in client runtime. To be consistent
139-
// with earlier code, we use installRoot as instanceRoot.
136+
// In client container, instanceRoot is not set.
137+
// It is a different question altogether as to why
138+
// an object called ServerEnvironmentImpl is at all active in client runtime.
139+
// To be consistent with earlier code, we use installRoot as instanceRoot.
140140
instanceRoot = installRoot;
141141
}
142142
root = new File(instanceRoot);
143143
}
144144
}
145145

146-
/*
147-
* bnevins 12/12/11
148-
* The following chunk of code sets things like hostname to be a file under instance root
149-
* I.e. it's crazy. It's 1 hour until SCF so I'll just fix the current problem which is a NPE
150-
* if the value is null.
151-
* At any rate the weird values that get set into System Properties get un-done at
152-
* the line of code in bootstrap (see end of this comment). It's easy to trace just step out of this method
153-
* in a debugger
154-
* createGlassFish(gfKernel, habitat, gfProps.getProperties())
155-
*/
156146
asenv.getProps().put(INSTANCE_ROOT.getPropertyName(), root.getAbsolutePath());
157147
for (Map.Entry<String, String> entry : asenv.getProps().entrySet()) {
158-
159-
if (entry.getValue() == null) { // don't NPE File ctor
148+
if (entry.getValue() == null) {
160149
continue;
161150
}
162-
163-
File location = new File(entry.getValue());
164-
if (!location.isAbsolute()) {
165-
location = new File(asenv.getProps().get(INSTANCE_ROOT.getPropertyName()), entry.getValue());
166-
}
167-
System.setProperty(entry.getKey(), location.getAbsolutePath());
151+
System.setProperty(entry.getKey(), entry.getValue());
168152
}
169153

170154
Properties args = startupContext.getArguments();

0 commit comments

Comments
 (0)