Skip to content

Commit

Permalink
Use BuildInfo in DisplayHelp and Console servlets. (#2766)
Browse files Browse the repository at this point in the history
  • Loading branch information
mach6 authored and lukeis committed Sep 12, 2016
1 parent eb6c8b2 commit b96b13f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import com.google.common.io.ByteStreams;

import org.openqa.selenium.internal.BuildInfo;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.jar.Manifest;
import java.util.logging.Logger;

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

public DisplayHelpServlet() {
getVersion();
coreVersion = new BuildInfo().getReleaseLabel();
}


Expand Down Expand Up @@ -86,25 +86,4 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
response.flushBuffer();
}
}

private void getVersion() {
InputStream stream = null;
try {
String classPath = this.getClass().getResource(this.getClass().getSimpleName() + ".class").toString();
String manifest = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
stream = new URL(manifest).openStream();
} catch (Exception e) {
e.printStackTrace();
}
if (stream == null) {
log.severe("Couldn't determine version number");
return;
}
try {
Manifest manifest = new Manifest(stream);
coreVersion = manifest.getEntries().get("Build-Info").getValue("Selenium-Version").trim();
} catch (IOException e) {
log.severe("Cannot load version from VERSION.txt" + e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,14 @@
import org.openqa.grid.internal.utils.HtmlRenderer;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.servlet.RegistryBasedServlet;
import org.openqa.selenium.internal.BuildInfo;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.jar.Manifest;
import java.util.logging.Logger;

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

public ConsoleServlet(Registry registry) {
super(registry);
getVersion();
coreVersion = new BuildInfo().getReleaseLabel();
}

@Override
Expand Down Expand Up @@ -245,25 +242,4 @@ private String getConfigInfo(boolean verbose) {
private String prettyHtmlPrint(GridHubConfiguration config) {
return config.toString("<abbr title='%1$s'>%1$s : </abbr>%2$s</br>");
}

private void getVersion() {
InputStream stream = null;
try {
String classPath = this.getClass().getResource(this.getClass().getSimpleName() + ".class").toString();
String manifest = classPath.substring(0, classPath.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
stream = new URL(manifest).openStream();
} catch (Exception e) {
e.printStackTrace();
}
if (stream == null) {
log.severe("Couldn't determine version number");
return;
}
try {
Manifest manifest = new Manifest(stream);
coreVersion = manifest.getEntries().get("Build-Info").getValue("Selenium-Version").trim();
} catch (IOException e) {
log.severe("Cannot load version from VERSION.txt" + e.getMessage());
}
}
}

0 comments on commit b96b13f

Please sign in to comment.