Merge branch 'stable-2.14' into stable-2.15
* stable-2.14: Increase the value of GERRIT_FDS parameter Fix invalid operator invalidating web session Change-Id: Ifc9403f870f65f19e2f9d6c42a9754bbb07201bf
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
load("//tools/bzl:genrule2.bzl", "genrule2")
|
load("//tools/bzl:genrule2.bzl", "genrule2")
|
||||||
load("//tools/bzl:junit.bzl", "junit_tests")
|
load("//tools/bzl:junit.bzl", "junit_tests")
|
||||||
|
|
||||||
QUERY_PARSE_EXCEPTION_SRCS = ["src/main/java/com/google/gerrit/index/query/QueryParseException.java"]
|
QUERY_PARSE_EXCEPTION_SRCS = [
|
||||||
|
"src/main/java/com/google/gerrit/index/query/QueryParseException.java",
|
||||||
|
"src/main/java/com/google/gerrit/index/query/QueryRequiresAuthException.java",
|
||||||
|
]
|
||||||
|
|
||||||
java_library(
|
java_library(
|
||||||
name = "query_exception",
|
name = "query_exception",
|
||||||
|
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (C) 2017 The Android Open Source Project
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package com.google.gerrit.index.query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception thrown when a search query is invalid.
|
||||||
|
*
|
||||||
|
* <p><b>NOTE:</b> the message is visible to end users.
|
||||||
|
*/
|
||||||
|
public class QueryRequiresAuthException extends QueryParseException {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public QueryRequiresAuthException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryRequiresAuthException(String msg, Throwable why) {
|
||||||
|
super(msg, why);
|
||||||
|
}
|
||||||
|
}
|
@@ -289,7 +289,11 @@ fi
|
|||||||
|
|
||||||
GERRIT_FDS=`get_config --int core.packedGitOpenFiles`
|
GERRIT_FDS=`get_config --int core.packedGitOpenFiles`
|
||||||
test -z "$GERRIT_FDS" && GERRIT_FDS=128
|
test -z "$GERRIT_FDS" && GERRIT_FDS=128
|
||||||
GERRIT_FDS=`expr $GERRIT_FDS + $GERRIT_FDS`
|
FDS_MULTIPLIER=2
|
||||||
|
USE_LFS=`get_config --get lfs.plugin`
|
||||||
|
test -n "$USE_LFS" && FDS_MULTIPLIER=3
|
||||||
|
|
||||||
|
GERRIT_FDS=`expr $FDS_MULTIPLIER \* $GERRIT_FDS`
|
||||||
test $GERRIT_FDS -lt 1024 && GERRIT_FDS=1024
|
test $GERRIT_FDS -lt 1024 && GERRIT_FDS=1024
|
||||||
|
|
||||||
GERRIT_STARTUP_TIMEOUT=`get_config --get container.startupTimeout`
|
GERRIT_STARTUP_TIMEOUT=`get_config --get container.startupTimeout`
|
||||||
|
@@ -36,6 +36,7 @@ import com.google.gerrit.index.query.LimitPredicate;
|
|||||||
import com.google.gerrit.index.query.Predicate;
|
import com.google.gerrit.index.query.Predicate;
|
||||||
import com.google.gerrit.index.query.QueryBuilder;
|
import com.google.gerrit.index.query.QueryBuilder;
|
||||||
import com.google.gerrit.index.query.QueryParseException;
|
import com.google.gerrit.index.query.QueryParseException;
|
||||||
|
import com.google.gerrit.index.query.QueryRequiresAuthException;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.reviewdb.client.Branch;
|
import com.google.gerrit.reviewdb.client.Branch;
|
||||||
@@ -391,23 +392,23 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
return asUser(userFactory.create(otherId));
|
return asUser(userFactory.create(otherId));
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentifiedUser getIdentifiedUser() throws QueryParseException {
|
IdentifiedUser getIdentifiedUser() throws QueryRequiresAuthException {
|
||||||
try {
|
try {
|
||||||
CurrentUser u = getUser();
|
CurrentUser u = getUser();
|
||||||
if (u.isIdentifiedUser()) {
|
if (u.isIdentifiedUser()) {
|
||||||
return u.asIdentifiedUser();
|
return u.asIdentifiedUser();
|
||||||
}
|
}
|
||||||
throw new QueryParseException(NotSignedInException.MESSAGE);
|
throw new QueryRequiresAuthException(NotSignedInException.MESSAGE);
|
||||||
} catch (ProvisionException e) {
|
} catch (ProvisionException e) {
|
||||||
throw new QueryParseException(NotSignedInException.MESSAGE, e);
|
throw new QueryRequiresAuthException(NotSignedInException.MESSAGE, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentUser getUser() throws QueryParseException {
|
CurrentUser getUser() throws QueryRequiresAuthException {
|
||||||
try {
|
try {
|
||||||
return self.get();
|
return self.get();
|
||||||
} catch (ProvisionException e) {
|
} catch (ProvisionException e) {
|
||||||
throw new QueryParseException(NotSignedInException.MESSAGE, e);
|
throw new QueryRequiresAuthException(NotSignedInException.MESSAGE, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,6 +24,7 @@ import com.google.gerrit.extensions.restapi.BadRequestException;
|
|||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||||
import com.google.gerrit.index.query.QueryParseException;
|
import com.google.gerrit.index.query.QueryParseException;
|
||||||
|
import com.google.gerrit.index.query.QueryRequiresAuthException;
|
||||||
import com.google.gerrit.index.query.QueryResult;
|
import com.google.gerrit.index.query.QueryResult;
|
||||||
import com.google.gerrit.server.change.ChangeJson;
|
import com.google.gerrit.server.change.ChangeJson;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
@@ -32,8 +33,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
|
|
||||||
public class QueryChanges implements RestReadView<TopLevelResource> {
|
public class QueryChanges implements RestReadView<TopLevelResource> {
|
||||||
@@ -106,15 +105,9 @@ public class QueryChanges implements RestReadView<TopLevelResource> {
|
|||||||
List<List<ChangeInfo>> out;
|
List<List<ChangeInfo>> out;
|
||||||
try {
|
try {
|
||||||
out = query();
|
out = query();
|
||||||
|
} catch (QueryRequiresAuthException e) {
|
||||||
|
throw new AuthException("Must be signed-in to use this operator");
|
||||||
} catch (QueryParseException e) {
|
} catch (QueryParseException e) {
|
||||||
// This is a hack to detect an operator that requires authentication.
|
|
||||||
Pattern p =
|
|
||||||
Pattern.compile("^Error in operator (.*:self|is:watched|is:owner|is:reviewer|has:.*)$");
|
|
||||||
Matcher m = p.matcher(e.getMessage());
|
|
||||||
if (m.matches()) {
|
|
||||||
String op = m.group(1);
|
|
||||||
throw new AuthException("Must be signed-in to use " + op);
|
|
||||||
}
|
|
||||||
throw new BadRequestException(e.getMessage(), e);
|
throw new BadRequestException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
return out.size() == 1 ? out.get(0) : out;
|
return out.size() == 1 ? out.get(0) : out;
|
||||||
|
Reference in New Issue
Block a user