From 530484379e0b329b57936388417fe02b339ae85b Mon Sep 17 00:00:00 2001 From: Bernhard Messer Date: Thu, 1 Dec 2005 21:15:53 +0000 Subject: [PATCH] avoid ArrayIndexOutOfBoundsException when startet without index parameter and print usage instead. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@351472 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/lucene/search/RemoteSearchable.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/lucene/search/RemoteSearchable.java b/src/java/org/apache/lucene/search/RemoteSearchable.java index c7bca31bf0e..aa09245214e 100644 --- a/src/java/org/apache/lucene/search/RemoteSearchable.java +++ b/src/java/org/apache/lucene/search/RemoteSearchable.java @@ -26,7 +26,11 @@ import java.rmi.server.UnicastRemoteObject; import org.apache.lucene.document.Document; import org.apache.lucene.index.Term; -/** A remote searchable implementation. */ +/** + * A remote searchable implementation. + * + * @version $Id$ + */ public class RemoteSearchable extends UnicastRemoteObject implements Searchable { @@ -111,12 +115,22 @@ public class RemoteSearchable /** Exports a searcher for the index in args[0] named * "//localhost/Searchable". */ public static void main(String args[]) throws Exception { + String indexName = null; + + if (args != null && args.length == 1) + indexName = args[0]; + + if (indexName == null) { + System.out.println("Usage: org.apache.lucene.search.RemoteSearchable "); + return; + } + // create and install a security manager if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } - Searchable local = new IndexSearcher(args[0]); + Searchable local = new IndexSearcher(indexName); RemoteSearchable impl = new RemoteSearchable(local); // bind the implementation to "Searchable"