Make sure all conditionals and loops are in blocks (too bug-prone otherwise)
git-svn-id: http://google-refine.googlecode.com/svn/trunk@2183 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
c16a2378f9
commit
da7347e7b1
@ -402,7 +402,9 @@ public class DataExtensionChange implements Change {
|
||||
for (int i = 0; i < count; i++) {
|
||||
line = reader.readLine();
|
||||
|
||||
if (line == null) continue;
|
||||
if (line == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.length() == 0) {
|
||||
dataExtensions.add(null);
|
||||
|
@ -162,12 +162,16 @@ public class RefineServlet extends Butterfly {
|
||||
Command command = commands.get(commandKey);
|
||||
if (command != null) {
|
||||
if (request.getMethod().equals("GET")) {
|
||||
if (!logger.isTraceEnabled()) logger.info("GET {}", request.getPathInfo());
|
||||
if (!logger.isTraceEnabled()) {
|
||||
logger.info("GET {}", request.getPathInfo());
|
||||
}
|
||||
logger.trace("> GET {}", commandKey);
|
||||
command.doGet(request, response);
|
||||
logger.trace("< GET {}", commandKey);
|
||||
} else if (request.getMethod().equals("POST")) {
|
||||
if (!logger.isTraceEnabled()) logger.info("POST {}", request.getPathInfo());
|
||||
if (!logger.isTraceEnabled()) {
|
||||
logger.info("POST {}", request.getPathInfo());
|
||||
}
|
||||
logger.trace("> POST {}", commandKey);
|
||||
command.doPost(request, response);
|
||||
logger.trace("< POST {}", commandKey);
|
||||
|
@ -112,7 +112,9 @@ abstract public class TimeBinIndex {
|
||||
|
||||
for (long step : steps) {
|
||||
_step = step;
|
||||
if (diff / _step <= 100) break;
|
||||
if (diff / _step <= 100) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_bins = new int[(int) (diff / _step) + 1];
|
||||
|
@ -96,7 +96,9 @@ public abstract class Command {
|
||||
*/
|
||||
static protected JSONObject getEngineConfig(HttpServletRequest request)
|
||||
throws JSONException {
|
||||
if (request == null) throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
}
|
||||
|
||||
String json = request.getParameter("engine");
|
||||
try{
|
||||
@ -118,13 +120,18 @@ public abstract class Command {
|
||||
*/
|
||||
static protected Engine getEngine(HttpServletRequest request, Project project)
|
||||
throws Exception {
|
||||
if (request == null) throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
if (project == null) throw new IllegalArgumentException("parameter 'project' should not be null");
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
}
|
||||
if (project == null) {
|
||||
throw new IllegalArgumentException("parameter 'project' should not be null");
|
||||
}
|
||||
|
||||
Engine engine = new Engine(project);
|
||||
JSONObject o = getEngineConfig(request);
|
||||
if (o != null)
|
||||
if (o != null) {
|
||||
engine.initializeFromJSON(o);
|
||||
}
|
||||
return engine;
|
||||
}
|
||||
|
||||
@ -167,7 +174,9 @@ public abstract class Command {
|
||||
* @throws ServletException
|
||||
*/
|
||||
protected ProjectMetadata getProjectMetadata(HttpServletRequest request) throws ServletException {
|
||||
if (request == null) throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
}
|
||||
try {
|
||||
ProjectMetadata pm = ProjectManager.singleton.getProjectMetadata(Long.parseLong(request.getParameter("project")));
|
||||
if (pm != null) {
|
||||
@ -180,7 +189,9 @@ public abstract class Command {
|
||||
}
|
||||
|
||||
static protected int getIntegerParameter(HttpServletRequest request, String name, int def) {
|
||||
if (request == null) throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(request.getParameter(name));
|
||||
} catch (Exception e) {
|
||||
@ -190,7 +201,9 @@ public abstract class Command {
|
||||
}
|
||||
|
||||
static protected JSONObject getJsonParameter(HttpServletRequest request, String name) {
|
||||
if (request == null) throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
}
|
||||
String value = request.getParameter(name);
|
||||
if (value != null) {
|
||||
try {
|
||||
|
@ -112,7 +112,9 @@ abstract public class HttpUtilities {
|
||||
}
|
||||
|
||||
static public int getIntegerParameter(HttpServletRequest request, String name, int def) {
|
||||
if (request == null) throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(request.getParameter(name));
|
||||
} catch (Exception e) {
|
||||
@ -122,7 +124,9 @@ abstract public class HttpUtilities {
|
||||
}
|
||||
|
||||
static public JSONObject getJsonParameter(HttpServletRequest request, String name) {
|
||||
if (request == null) throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
if (request == null) {
|
||||
throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
}
|
||||
String value = request.getParameter(name);
|
||||
if (value != null) {
|
||||
try {
|
||||
|
@ -22,30 +22,32 @@ public class ToggleStarredExpressionCommand extends Command {
|
||||
TopList starredExpressions = ((TopList) ProjectManager.singleton.getPreferenceStore().get(
|
||||
"scripting.starred-expressions"));
|
||||
|
||||
if (starredExpressions.getList().contains(expression))
|
||||
if (starredExpressions.getList().contains(expression)) {
|
||||
starredExpressions.remove(expression);
|
||||
else
|
||||
} else {
|
||||
starredExpressions.add(expression);
|
||||
}
|
||||
|
||||
if(request.getParameter("returnList") != null)
|
||||
try {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
if(request.getParameter("returnList") != null) {
|
||||
try {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
|
||||
JSONWriter writer = new JSONWriter(response.getWriter());
|
||||
writer.object();
|
||||
writer.key("expressions");
|
||||
writer.array();
|
||||
for (String s : starredExpressions) {
|
||||
JSONWriter writer = new JSONWriter(response.getWriter());
|
||||
writer.object();
|
||||
writer.key("code");
|
||||
writer.value(s);
|
||||
writer.key("expressions");
|
||||
writer.array();
|
||||
for (String s : starredExpressions) {
|
||||
writer.object();
|
||||
writer.key("code");
|
||||
writer.value(s);
|
||||
writer.endObject();
|
||||
}
|
||||
writer.endArray();
|
||||
writer.endObject();
|
||||
} catch (Exception e) {
|
||||
respondException(response, e);
|
||||
}
|
||||
writer.endArray();
|
||||
writer.endObject();
|
||||
} catch (Exception e) {
|
||||
respondException(response, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,8 +47,12 @@ public class CancelProcessesCommand extends Command {
|
||||
@Override
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
if( request == null ) throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
if( response == null ) throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
if( request == null ) {
|
||||
throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
}
|
||||
if( response == null ) {
|
||||
throw new IllegalArgumentException("parameter 'request' should not be null");
|
||||
}
|
||||
|
||||
try {
|
||||
Project project = getProject(request);
|
||||
|
@ -46,21 +46,26 @@ public class Combin implements Function {
|
||||
|
||||
@Override
|
||||
public Object call(Properties bindings, Object[] args) {
|
||||
if(args.length != 2)
|
||||
if(args.length != 2) {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects two numbers");
|
||||
if(args[0] == null || !(args[0] instanceof Number))
|
||||
}
|
||||
if(args[0] == null || !(args[0] instanceof Number)) {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects the first argument to be a number");
|
||||
if(args[1] == null || !(args[1] instanceof Number))
|
||||
}
|
||||
if(args[1] == null || !(args[1] instanceof Number)) {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects the second argument to be a number");
|
||||
}
|
||||
|
||||
return Combin.Combination(((Number) args[0]).intValue(), ((Number) args[1]).intValue());
|
||||
}
|
||||
|
||||
public static int Combination(int n, int k){
|
||||
if (k > n)
|
||||
if (k > n) {
|
||||
throw new IllegalArgumentException ("the number of elements, n, should be larger than the number of combinations, k");
|
||||
if (n < 1)
|
||||
}
|
||||
if (n < 1) {
|
||||
throw new IllegalArgumentException ("the number of elements, n, cannot be less than 1");
|
||||
}
|
||||
int nFact = FactN.factorial(n, 1);
|
||||
int rFact = FactN.factorial(k, 1);
|
||||
int nminusrFact = FactN.factorial(n - k, 1);
|
||||
|
@ -46,12 +46,15 @@ public class FactN implements Function {
|
||||
|
||||
@Override
|
||||
public Object call(Properties bindings, Object[] args) {
|
||||
if (args.length != 2)
|
||||
if (args.length != 2) {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects two numbers");
|
||||
if(args[0] == null || !(args[0] instanceof Number))
|
||||
}
|
||||
if(args[0] == null || !(args[0] instanceof Number)) {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects the first parameter to be a number");
|
||||
if(args[1] == null && !(args[1] instanceof Number))
|
||||
}
|
||||
if(args[1] == null && !(args[1] instanceof Number)) {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects the second parameter to be a number");
|
||||
}
|
||||
|
||||
return FactN.factorial(((Number) args[0]).intValue(), ((Number) args[1]).intValue());
|
||||
|
||||
@ -63,10 +66,11 @@ public class FactN implements Function {
|
||||
* Returns 1 for zero and negative integers.
|
||||
*/
|
||||
public static int factorial(int i, int step){
|
||||
if(i <= 1)
|
||||
if(i <= 1) {
|
||||
return 1;
|
||||
else
|
||||
} else {
|
||||
return i * FactN.factorial(i - step, step);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,8 +62,9 @@ public class LeastCommonMultiple implements Function {
|
||||
smallerValue = a;
|
||||
}
|
||||
for(int i = 1; i <= largerValue; i++){
|
||||
if((largerValue*i) % smallerValue == 0)
|
||||
if((largerValue*i) % smallerValue == 0) {
|
||||
return largerValue * i;
|
||||
}
|
||||
}
|
||||
return largerValue * smallerValue;
|
||||
}
|
||||
|
@ -46,13 +46,15 @@ public class Multinomial implements Function {
|
||||
|
||||
@Override
|
||||
public Object call(Properties bindings, Object[] args) {
|
||||
if (args.length < 1)
|
||||
if (args.length < 1) {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects one or more numbers");
|
||||
}
|
||||
int sum = 0;
|
||||
int product = 1;
|
||||
for(int i = 0; i < args.length; i++){
|
||||
if(args[i] == null && !(args[i] instanceof Number))
|
||||
if(args[i] == null && !(args[i] instanceof Number)) {
|
||||
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects parameter " + (i + 1) + " to be a number");
|
||||
}
|
||||
int num = ((Number) args[i]).intValue();
|
||||
sum += num;
|
||||
product *= FactN.factorial(num, 1);
|
||||
|
@ -63,16 +63,30 @@ public class Diff implements Function {
|
||||
Date c1 = (o1 instanceof Date) ? (Date) o1 : ((Calendar) o1).getTime();
|
||||
Date c2 = (o2 instanceof Date) ? (Date) o2 : CalendarParser.parse((o2 instanceof String) ? (String) o2 : o2.toString()).getTime();
|
||||
long delta = (c1.getTime() - c2.getTime()) / 1000;
|
||||
if ("seconds".equals(unit)) return delta;
|
||||
if ("seconds".equals(unit)) {
|
||||
return delta;
|
||||
}
|
||||
delta /= 60;
|
||||
if ("minutes".equals(unit)) return delta;
|
||||
if ("minutes".equals(unit)) {
|
||||
return delta;
|
||||
}
|
||||
delta /= 60;
|
||||
if ("hours".equals(unit)) return delta;
|
||||
if ("hours".equals(unit)) {
|
||||
return delta;
|
||||
}
|
||||
long days = delta / 24;
|
||||
if ("days".equals(unit)) return days;
|
||||
if ("weeks".equals(unit)) return days / 7;
|
||||
if ("months".equals(unit)) return days / 30;
|
||||
if ("years".equals(unit)) return days / 365;
|
||||
if ("days".equals(unit)) {
|
||||
return days;
|
||||
}
|
||||
if ("weeks".equals(unit)) {
|
||||
return days / 7;
|
||||
}
|
||||
if ("months".equals(unit)) {
|
||||
return days / 30;
|
||||
}
|
||||
if ("years".equals(unit)) {
|
||||
return days / 365;
|
||||
}
|
||||
} catch (CalendarParserException e) {
|
||||
// we should throw at this point because it's important to know that date parsing failed
|
||||
}
|
||||
|
@ -64,7 +64,9 @@ public class Phonetic implements Function {
|
||||
if (o1 != null && o2 != null && o2 instanceof String) {
|
||||
String str = (o1 instanceof String) ? (String) o1 : o1.toString();
|
||||
String encoding = ((String) o2).toLowerCase();
|
||||
if (encoding == null) encoding = "metaphone3";
|
||||
if (encoding == null) {
|
||||
encoding = "metaphone3";
|
||||
}
|
||||
if ("doublemetaphone".equalsIgnoreCase(encoding)) {
|
||||
return metaphone2.key(str);
|
||||
} else if ("metaphone3".equalsIgnoreCase(encoding)) {
|
||||
|
@ -43,7 +43,9 @@ public class IsNumeric extends IsTest {
|
||||
|
||||
@Override
|
||||
protected boolean test(Object o) {
|
||||
if (o instanceof Number) return true;
|
||||
if (o instanceof Number) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String s = (o instanceof String) ? (String) o : o.toString();
|
||||
|
||||
|
@ -79,7 +79,9 @@ public class ChangeSequence implements Change {
|
||||
|
||||
static public Change load(LineNumberReader reader, Pool pool) throws Exception {
|
||||
String line = reader.readLine();
|
||||
if (line == null) line = "";
|
||||
if (line == null) {
|
||||
line = "";
|
||||
}
|
||||
int equal = line.indexOf('=');
|
||||
|
||||
assert "count".equals(line.substring(0, equal));
|
||||
|
@ -261,10 +261,11 @@ public class JsonImporter extends TreeImportingParserBase {
|
||||
|
||||
//The following is a workaround for inconsistent Jackson JsonParser
|
||||
if(text == null){
|
||||
if(this.lastTokenWasAFieldNameAndCurrentTokenIsANewEntity)
|
||||
if(this.lastTokenWasAFieldNameAndCurrentTokenIsANewEntity) {
|
||||
text = this.lastFieldName;
|
||||
else
|
||||
} else {
|
||||
text = "__anonymous__";
|
||||
}
|
||||
}
|
||||
//end of workaround
|
||||
|
||||
@ -307,8 +308,9 @@ public class JsonImporter extends TreeImportingParserBase {
|
||||
throw new ServletException(e);
|
||||
}
|
||||
|
||||
if(next == null)
|
||||
if(next == null) {
|
||||
throw new ServletException("No more Json Tokens in stream");
|
||||
}
|
||||
|
||||
//The following is a workaround for inconsistent Jackson JsonParser
|
||||
if(next == JsonToken.FIELD_NAME){
|
||||
|
@ -91,8 +91,9 @@ public class XmlImportUtilities extends TreeImportUtilities {
|
||||
*/
|
||||
static protected List<String> detectRecordElement(TreeReader parser, String tag) throws Exception {
|
||||
try{
|
||||
if(parser.current() == Token.Ignorable)//XMLStreamConstants.START_DOCUMENT)
|
||||
if(parser.current() == Token.Ignorable) {
|
||||
parser.next();
|
||||
}
|
||||
|
||||
String localName = parser.getFieldName();
|
||||
String fullName = composeName(parser.getPrefix(), localName);
|
||||
@ -392,8 +393,9 @@ public class XmlImportUtilities extends TreeImportUtilities {
|
||||
) throws Exception {
|
||||
logger.trace("processSubRecord(Project,TreeReader,ImportColumnGroup,ImportRecord)");
|
||||
|
||||
if(parser.current() == Token.Ignorable)
|
||||
if(parser.current() == Token.Ignorable) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImportColumnGroup thisColumnGroup = getColumnGroup(
|
||||
project,
|
||||
|
@ -318,9 +318,15 @@ public class FileProjectManager extends ProjectManager {
|
||||
}
|
||||
|
||||
protected void load() {
|
||||
if (loadFromFile(new File(_workspaceDir, "workspace.json"))) return;
|
||||
if (loadFromFile(new File(_workspaceDir, "workspace.temp.json"))) return;
|
||||
if (loadFromFile(new File(_workspaceDir, "workspace.old.json"))) return;
|
||||
if (loadFromFile(new File(_workspaceDir, "workspace.json"))) {
|
||||
return;
|
||||
}
|
||||
if (loadFromFile(new File(_workspaceDir, "workspace.temp.json"))) {
|
||||
return;
|
||||
}
|
||||
if (loadFromFile(new File(_workspaceDir, "workspace.old.json"))) {
|
||||
return;
|
||||
}
|
||||
logger.error("Failed to load workspace from any attempted alternatives.");
|
||||
}
|
||||
|
||||
|
@ -93,12 +93,18 @@ public class IndentingLayout extends Layout {
|
||||
@Override
|
||||
public String format(LoggingEvent event) {
|
||||
String message = event.getRenderedMessage();
|
||||
if (message == null) return "";
|
||||
if (message.length() < 2) return message;
|
||||
if (message == null) {
|
||||
return "";
|
||||
}
|
||||
if (message.length() < 2) {
|
||||
return message;
|
||||
}
|
||||
|
||||
char leader = message.charAt(0);
|
||||
char secondLeader = message.charAt(1);
|
||||
if ((leader == '<') && (secondLeader == ' ') && (this.indentation > 0)) this.indentation--;
|
||||
if ((leader == '<') && (secondLeader == ' ') && (this.indentation > 0)) {
|
||||
this.indentation--;
|
||||
}
|
||||
|
||||
// Reset buf
|
||||
StringBuffer buf = new StringBuffer(256);
|
||||
@ -120,23 +126,33 @@ public class IndentingLayout extends Layout {
|
||||
// }
|
||||
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
if (hour < 10) buf.append('0');
|
||||
if (hour < 10) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(hour);
|
||||
buf.append(':');
|
||||
|
||||
int mins = calendar.get(Calendar.MINUTE);
|
||||
if (mins < 10) buf.append('0');
|
||||
if (mins < 10) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(mins);
|
||||
buf.append(':');
|
||||
|
||||
int secs = calendar.get(Calendar.SECOND);
|
||||
if (secs < 10) buf.append('0');
|
||||
if (secs < 10) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(secs);
|
||||
buf.append('.');
|
||||
|
||||
int millis = (int) (now % 1000);
|
||||
if (millis < 100) buf.append('0');
|
||||
if (millis < 10) buf.append('0');
|
||||
if (millis < 100) {
|
||||
buf.append('0');
|
||||
}
|
||||
if (millis < 10) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(millis);
|
||||
|
||||
buf.append(" [");
|
||||
@ -161,7 +177,9 @@ public class IndentingLayout extends Layout {
|
||||
buf.append(delta);
|
||||
buf.append("ms)\n");
|
||||
|
||||
if ((leader == '>') && (secondLeader == ' ')) indentation++;
|
||||
if ((leader == '>') && (secondLeader == ' ')) {
|
||||
indentation++;
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
@ -348,7 +348,9 @@ public class ColumnSplitChange implements Change {
|
||||
for (int i = 0; i < count; i++) {
|
||||
line = reader.readLine();
|
||||
|
||||
if (line == null) continue;
|
||||
if (line == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int valueCount = Integer.parseInt(line);
|
||||
|
||||
|
@ -58,7 +58,9 @@ public class Credentials {
|
||||
}
|
||||
|
||||
public String getCookieName(Provider provider) {
|
||||
if (provider == null) throw new RuntimeException("Provider can't be null");
|
||||
if (provider == null) {
|
||||
throw new RuntimeException("Provider can't be null");
|
||||
}
|
||||
return provider.getHost() + "_" + postfix;
|
||||
}
|
||||
};
|
||||
@ -89,11 +91,17 @@ public class Credentials {
|
||||
|
||||
public Credentials(String token, String secret, Provider provider) {
|
||||
this.token = token;
|
||||
if (token == null) throw new RuntimeException("Could not find " + TOKEN + " in auth credentials");
|
||||
if (token == null) {
|
||||
throw new RuntimeException("Could not find " + TOKEN + " in auth credentials");
|
||||
}
|
||||
this.secret = secret;
|
||||
if (secret == null) throw new RuntimeException("Could not find " + SECRET + " in auth credentials");
|
||||
if (secret == null) {
|
||||
throw new RuntimeException("Could not find " + SECRET + " in auth credentials");
|
||||
}
|
||||
this.provider = provider;
|
||||
if (provider == null) throw new RuntimeException("Provider can't be null");
|
||||
if (provider == null) {
|
||||
throw new RuntimeException("Provider can't be null");
|
||||
}
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
|
@ -62,14 +62,20 @@ public class OAuthUtilities {
|
||||
int slash = path.lastIndexOf('/');
|
||||
String provider_str = path.substring(slash + 1);
|
||||
Provider provider = getProvider(provider_str);
|
||||
if (provider == null) throw new RuntimeException("Can't find OAuth provider '" + provider_str + "'");
|
||||
if (provider == null) {
|
||||
throw new RuntimeException("Can't find OAuth provider '" + provider_str + "'");
|
||||
}
|
||||
return provider;
|
||||
}
|
||||
|
||||
public static OAuthConsumer getConsumer(Provider provider) {
|
||||
if (provider == null) throw new RuntimeException("Provider can't be null");
|
||||
if (provider == null) {
|
||||
throw new RuntimeException("Provider can't be null");
|
||||
}
|
||||
String[] consumer_info = infos.get(provider.getHost());
|
||||
if (consumer_info == null) throw new RuntimeException("Can't find secrets for provider '" + provider.getHost() + "'");
|
||||
if (consumer_info == null) {
|
||||
throw new RuntimeException("Can't find secrets for provider '" + provider.getHost() + "'");
|
||||
}
|
||||
OAuthConsumer oauthConsumer = provider.createConsumer(consumer_info[0],consumer_info[1]);
|
||||
HttpParameters params = new HttpParameters();
|
||||
params.put("realm", provider.getHost());
|
||||
|
@ -43,7 +43,9 @@ public class CookiesUtilities {
|
||||
public static final String PATH = "/";
|
||||
|
||||
public static Cookie getCookie(HttpServletRequest request, String name) {
|
||||
if (name == null) throw new RuntimeException("cookie name cannot be null");
|
||||
if (name == null) {
|
||||
throw new RuntimeException("cookie name cannot be null");
|
||||
}
|
||||
Cookie cookie = null;
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if (cookies != null) {
|
||||
@ -74,7 +76,9 @@ public class CookiesUtilities {
|
||||
|
||||
public static String getDomain(HttpServletRequest request) {
|
||||
String host = request.getHeader("Host");
|
||||
if (host == null) return DOMAIN;
|
||||
if (host == null) {
|
||||
return DOMAIN;
|
||||
}
|
||||
int index = host.indexOf(':');
|
||||
return (index > -1) ? host.substring(0,index) : host ;
|
||||
}
|
||||
|
@ -109,7 +109,9 @@ public class ParsingUtilities {
|
||||
}
|
||||
|
||||
static public JSONObject evaluateJsonStringToObject(String s) throws JSONException {
|
||||
if( s == null ) throw new IllegalArgumentException("parameter 's' should not be null");
|
||||
if( s == null ) {
|
||||
throw new IllegalArgumentException("parameter 's' should not be null");
|
||||
}
|
||||
JSONTokener t = new JSONTokener(s);
|
||||
Object o = t.nextValue();
|
||||
if (o instanceof JSONObject) {
|
||||
|
@ -131,8 +131,9 @@ public class ImporterUtilitiesTests extends RefineTest {
|
||||
@Test
|
||||
public void ensureColumnsInRowExistDoesExpand(){
|
||||
Row row = new Row(4);
|
||||
for(int i = 1; i < 5; i++)
|
||||
for(int i = 1; i < 5; i++) {
|
||||
row.cells.add(new Cell("value" + i, null));
|
||||
}
|
||||
|
||||
ArrayList<String> columnNames = new ArrayList<String>(2);
|
||||
|
||||
|
@ -186,8 +186,9 @@ public class JsonImporterTests extends ImporterTest {
|
||||
try{
|
||||
while(token != null){
|
||||
token = parser.next();
|
||||
if(token == null)
|
||||
if(token == null) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
if(i == 3){
|
||||
Assert.assertEquals(Token.Value, token);
|
||||
@ -205,8 +206,9 @@ public class JsonImporterTests extends ImporterTest {
|
||||
try{
|
||||
while(token != null){
|
||||
token = parser.next();
|
||||
if(token == null)
|
||||
if(token == null) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
if(i == 3){
|
||||
Assert.assertEquals(Token.StartEntity, token);
|
||||
@ -223,8 +225,9 @@ public class JsonImporterTests extends ImporterTest {
|
||||
try{
|
||||
while(token != null){
|
||||
token = parser.next();
|
||||
if(token == null)
|
||||
if(token == null) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
if(i == 3){
|
||||
Assert.assertEquals(token, Token.StartEntity);
|
||||
|
@ -93,8 +93,9 @@ public class XmlImportUtilitiesTests extends RefineTest {
|
||||
parser = null;
|
||||
columnGroup = null;
|
||||
record = null;
|
||||
if(inputStream != null)
|
||||
inputStream.close();
|
||||
if(inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
inputStream = null;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,9 @@ class RefineServer extends Server {
|
||||
logger.info("Starting Server bound to '" + host + ":" + port + "'");
|
||||
|
||||
String memory = Configurations.get("refine.memory");
|
||||
if (memory != null) logger.info("Max memory size: " + memory);
|
||||
if (memory != null) {
|
||||
logger.info("Max memory size: " + memory);
|
||||
}
|
||||
|
||||
int maxThreads = Configurations.getInteger("refine.queue.size", 30);
|
||||
int maxQueue = Configurations.getInteger("refine.queue.max_size", 300);
|
||||
@ -200,7 +202,9 @@ class RefineServer extends Server {
|
||||
protected void doStop() throws Exception {
|
||||
try {
|
||||
// shutdown our scheduled tasks first, if any
|
||||
if (threadPool != null) threadPool.shutdown();
|
||||
if (threadPool != null) {
|
||||
threadPool.shutdown();
|
||||
}
|
||||
|
||||
// then let the parent stop
|
||||
super.doStop();
|
||||
@ -210,8 +214,12 @@ class RefineServer extends Server {
|
||||
}
|
||||
|
||||
static private boolean isWebapp(File dir) {
|
||||
if (dir == null) return false;
|
||||
if (!dir.exists() || !dir.canRead()) return false;
|
||||
if (dir == null) {
|
||||
return false;
|
||||
}
|
||||
if (!dir.exists() || !dir.canRead()) {
|
||||
return false;
|
||||
}
|
||||
File webXml = new File(dir, "WEB-INF/web.xml");
|
||||
return webXml.exists() && webXml.canRead();
|
||||
}
|
||||
|
@ -60,12 +60,18 @@ public class IndentingLayout extends Layout {
|
||||
@Override
|
||||
public String format(LoggingEvent event) {
|
||||
String message = event.getRenderedMessage();
|
||||
if (message == null) return "";
|
||||
if (message.length() < 2) return message;
|
||||
if (message == null) {
|
||||
return "";
|
||||
}
|
||||
if (message.length() < 2) {
|
||||
return message;
|
||||
}
|
||||
|
||||
char leader = message.charAt(0);
|
||||
char secondLeader = message.charAt(1);
|
||||
if ((leader == '<') && (secondLeader == ' ') && (this.indentation > 0)) this.indentation--;
|
||||
if ((leader == '<') && (secondLeader == ' ') && (this.indentation > 0)) {
|
||||
this.indentation--;
|
||||
}
|
||||
|
||||
// Reset buf
|
||||
StringBuffer buf = new StringBuffer(256);
|
||||
@ -87,23 +93,33 @@ public class IndentingLayout extends Layout {
|
||||
// }
|
||||
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
if (hour < 10) buf.append('0');
|
||||
if (hour < 10) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(hour);
|
||||
buf.append(':');
|
||||
|
||||
int mins = calendar.get(Calendar.MINUTE);
|
||||
if (mins < 10) buf.append('0');
|
||||
if (mins < 10) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(mins);
|
||||
buf.append(':');
|
||||
|
||||
int secs = calendar.get(Calendar.SECOND);
|
||||
if (secs < 10) buf.append('0');
|
||||
if (secs < 10) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(secs);
|
||||
buf.append('.');
|
||||
|
||||
int millis = (int) (now % 1000);
|
||||
if (millis < 100) buf.append('0');
|
||||
if (millis < 10) buf.append('0');
|
||||
if (millis < 100) {
|
||||
buf.append('0');
|
||||
}
|
||||
if (millis < 10) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(millis);
|
||||
|
||||
buf.append(" [");
|
||||
@ -128,7 +144,9 @@ public class IndentingLayout extends Layout {
|
||||
buf.append(delta);
|
||||
buf.append("ms)\n");
|
||||
|
||||
if ((leader == '>') && (secondLeader == ' ')) indentation++;
|
||||
if ((leader == '>') && (secondLeader == ' ')) {
|
||||
indentation++;
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user