1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.server;
20
21 import java.io.File;
22 import java.io.IOException;
23 import java.nio.file.Files;
24 import java.nio.file.Path;
25
26 import org.eclipse.jetty.util.StringUtil;
27 import org.eclipse.jetty.util.log.Log;
28 import org.eclipse.jetty.util.log.Logger;
29
30
31
32
33
34
35 public class HomeBaseWarning
36 {
37 private static final Logger LOG = Log.getLogger(HomeBaseWarning.class);
38
39 public HomeBaseWarning()
40 {
41 boolean showWarn = false;
42
43 String home = System.getProperty("jetty.home");
44 String base = System.getProperty("jetty.base");
45
46 if (StringUtil.isBlank(base))
47 {
48
49
50 return;
51 }
52
53 Path homePath = new File(home).toPath();
54 Path basePath = new File(base).toPath();
55
56 try
57 {
58 showWarn = Files.isSameFile(homePath,basePath);
59 }
60 catch (IOException e)
61 {
62 LOG.ignore(e);
63
64 return;
65 }
66
67 if (showWarn)
68 {
69 StringBuilder warn = new StringBuilder();
70 warn.append("This instance of Jetty is not running from a separate {jetty.base} directory");
71 warn.append(", this is not recommended. See documentation at http://www.eclipse.org/jetty/documentation/current/startup.html");
72 LOG.warn("{}",warn.toString());
73 }
74 }
75 }