Skip to content

Commit b96b13f

Browse files
mach6lukeis
authored andcommitted
Use BuildInfo in DisplayHelp and Console servlets. (#2766)
1 parent eb6c8b2 commit b96b13f

File tree

2 files changed

+5
-50
lines changed

2 files changed

+5
-50
lines changed

java/server/src/org/openqa/grid/web/servlet/DisplayHelpServlet.java

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
import com.google.common.io.ByteStreams;
2121

22+
import org.openqa.selenium.internal.BuildInfo;
23+
2224
import java.io.ByteArrayInputStream;
2325
import java.io.IOException;
2426
import java.io.InputStream;
25-
import java.net.URL;
26-
import java.util.jar.Manifest;
2727
import java.util.logging.Logger;
2828

2929
import javax.servlet.ServletException;
@@ -37,7 +37,7 @@ public class DisplayHelpServlet extends HttpServlet {
3737
private static String coreVersion;
3838

3939
public DisplayHelpServlet() {
40-
getVersion();
40+
coreVersion = new BuildInfo().getReleaseLabel();
4141
}
4242

4343

@@ -86,25 +86,4 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
8686
response.flushBuffer();
8787
}
8888
}
89-
90-
private void getVersion() {
91-
InputStream stream = null;
92-
try {
93-
String classPath = this.getClass().getResource(this.getClass().getSimpleName() + ".class").toString();
94-
String manifest = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
95-
stream = new URL(manifest).openStream();
96-
} catch (Exception e) {
97-
e.printStackTrace();
98-
}
99-
if (stream == null) {
100-
log.severe("Couldn't determine version number");
101-
return;
102-
}
103-
try {
104-
Manifest manifest = new Manifest(stream);
105-
coreVersion = manifest.getEntries().get("Build-Info").getValue("Selenium-Version").trim();
106-
} catch (IOException e) {
107-
log.severe("Cannot load version from VERSION.txt" + e.getMessage());
108-
}
109-
}
11089
}

java/server/src/org/openqa/grid/web/servlet/beta/ConsoleServlet.java

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@
2525
import org.openqa.grid.internal.utils.HtmlRenderer;
2626
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
2727
import org.openqa.grid.web.servlet.RegistryBasedServlet;
28+
import org.openqa.selenium.internal.BuildInfo;
2829
import org.openqa.selenium.remote.DesiredCapabilities;
2930

3031
import java.io.ByteArrayInputStream;
3132
import java.io.IOException;
3233
import java.io.InputStream;
33-
import java.net.URL;
34-
import java.net.URLClassLoader;
3534
import java.util.ArrayList;
3635
import java.util.List;
37-
import java.util.Properties;
38-
import java.util.jar.Manifest;
3936
import java.util.logging.Logger;
4037

4138
import javax.servlet.ServletException;
@@ -54,7 +51,7 @@ public ConsoleServlet() {
5451

5552
public ConsoleServlet(Registry registry) {
5653
super(registry);
57-
getVersion();
54+
coreVersion = new BuildInfo().getReleaseLabel();
5855
}
5956

6057
@Override
@@ -245,25 +242,4 @@ private String getConfigInfo(boolean verbose) {
245242
private String prettyHtmlPrint(GridHubConfiguration config) {
246243
return config.toString("<abbr title='%1$s'>%1$s : </abbr>%2$s</br>");
247244
}
248-
249-
private void getVersion() {
250-
InputStream stream = null;
251-
try {
252-
String classPath = this.getClass().getResource(this.getClass().getSimpleName() + ".class").toString();
253-
String manifest = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
254-
stream = new URL(manifest).openStream();
255-
} catch (Exception e) {
256-
e.printStackTrace();
257-
}
258-
if (stream == null) {
259-
log.severe("Couldn't determine version number");
260-
return;
261-
}
262-
try {
263-
Manifest manifest = new Manifest(stream);
264-
coreVersion = manifest.getEntries().get("Build-Info").getValue("Selenium-Version").trim();
265-
} catch (IOException e) {
266-
log.severe("Cannot load version from VERSION.txt" + e.getMessage());
267-
}
268-
}
269245
}

0 commit comments

Comments
 (0)