提交 7936f195 authored 作者: Thomas Mueller's avatar Thomas Mueller

Server.createTcpServer, createPgServer, createWebServer: invalid arguments are now detected.

上级 ad43aaf7
...@@ -254,7 +254,7 @@ ShutdownHandler { ...@@ -254,7 +254,7 @@ ShutdownHandler {
// start browser in any case (even if the server is already running) // start browser in any case (even if the server is already running)
// because some people don't look at the output, // because some people don't look at the output,
// but are wondering why nothing happens // but are wondering why nothing happens
if (browserStart) { if (browserStart && web != null) {
openBrowser(web.getURL()); openBrowser(web.getURL());
} }
......
...@@ -171,6 +171,22 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -171,6 +171,22 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
} else { } else {
throwUnsupportedOption(arg); throwUnsupportedOption(arg);
} }
} else if (arg.startsWith("-ftp")) {
if ("-ftpPort".equals(arg)) {
i++;
} else if ("-ftpDir".equals(arg)) {
i++;
} else if ("-ftpRead".equals(arg)) {
i++;
} else if ("-ftpWrite".equals(arg)) {
i++;
} else if ("-ftpWritePassword".equals(arg)) {
i++;
} else if ("-ftpTask".equals(arg)) {
// no parameters
} else {
throwUnsupportedOption(arg);
}
} else if ("-properties".equals(arg)) { } else if ("-properties".equals(arg)) {
i++; i++;
} else if ("-trace".equals(arg)) { } else if ("-trace".equals(arg)) {
...@@ -179,6 +195,10 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -179,6 +195,10 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
// no parameters // no parameters
} else if ("-baseDir".equals(arg)) { } else if ("-baseDir".equals(arg)) {
i++; i++;
} else if ("-key".equals(arg)) {
i += 2;
} else if ("-tool".equals(arg)) {
// no parameters
} else { } else {
throwUnsupportedOption(arg); throwUnsupportedOption(arg);
} }
...@@ -261,6 +281,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -261,6 +281,8 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
// no parameters // no parameters
} else if ("-baseDir".equals(arg)) { } else if ("-baseDir".equals(arg)) {
i++; i++;
} else if ("-key".equals(arg)) {
i += 2;
} else { } else {
showUsageAndThrowUnsupportedOption(arg); showUsageAndThrowUnsupportedOption(arg);
} }
......
...@@ -11,6 +11,7 @@ import java.io.IOException; ...@@ -11,6 +11,7 @@ import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import org.h2.constant.ErrorCode;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.store.FileLister; import org.h2.store.FileLister;
import org.h2.store.fs.FileUtils; import org.h2.store.fs.FileUtils;
...@@ -62,7 +63,7 @@ public abstract class Tool { ...@@ -62,7 +63,7 @@ public abstract class Tool {
* @return this method never returns normally * @return this method never returns normally
*/ */
protected SQLException throwUnsupportedOption(String option) throws SQLException { protected SQLException throwUnsupportedOption(String option) throws SQLException {
throw new SQLException("Unsupported option: " + option); throw DbException.get(ErrorCode.FEATURE_NOT_SUPPORTED_1, option).getSQLException();
} }
/** /**
......
...@@ -448,7 +448,7 @@ public class TestTools extends TestBase { ...@@ -448,7 +448,7 @@ public class TestTools extends TestBase {
result = runServer(1, new String[]{"-xy"}); result = runServer(1, new String[]{"-xy"});
assertTrue(result.indexOf("Starts the H2 Console") >= 0); assertTrue(result.indexOf("Starts the H2 Console") >= 0);
assertTrue(result.indexOf("Unsupported option") >= 0); assertTrue(result.indexOf("Feature not supported") >= 0);
result = runServer(0, new String[]{"-tcp", "-tcpPort", "9001", "-tcpPassword", "abc"}); result = runServer(0, new String[]{"-tcp", "-tcpPort", "9001", "-tcpPassword", "abc"});
assertTrue(result.indexOf("tcp://") >= 0); assertTrue(result.indexOf("tcp://") >= 0);
assertTrue(result.indexOf(":9001") >= 0); assertTrue(result.indexOf(":9001") >= 0);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论