Merge branch 'stable-2.8' into stable-2.9

* stable-2.8:
  SideBySide2: Fix failure to load from "ISE EditIterator out of bounds"
  Remove "Click to" from topic edit button's tooltip
  Fix: wrongly throw 'commit already exists' exception
  Update sshd to 0.11.0
  Bump SSHD version to 0.10.1 and enable nio2 backend

Conflicts:
	gerrit-gwtui/src/main/java/com/google/gerrit/client/change/Topic.ui.xml

Change-Id: I63c1e12bbd413a8e212de5b2a8cf71fa2a2ce52d
This commit is contained in:
Shawn Pearce
2014-04-23 21:23:51 -07:00
7 changed files with 78 additions and 34 deletions

View File

@@ -2683,6 +2683,14 @@ namespace. To alias `replication start` to `gerrit replicate`:
[[sshd]] [[sshd]]
=== Section sshd === Section sshd
[[sshd.backend]]sshd.backend::
+
Starting from version 0.9.0 Apache SSHD project added support for NIO2
IoSession. To use the new NIO2 session the `backend` option must be set
to `NIO2`.
+
By default, `MINA`.
[[sshd.listenAddress]]sshd.listenAddress:: [[sshd.listenAddress]]sshd.listenAddress::
+ +
Specifies the local addresses the internal SSHD should listen Specifies the local addresses the internal SSHD should listen

View File

@@ -32,7 +32,7 @@ limitations under the License.
<g:Image ui:field='editIcon' <g:Image ui:field='editIcon'
resource='{ico.edit}' resource='{ico.edit}'
styleName='{style.edit}' styleName='{style.edit}'
title='Click to edit topic (Shortcut: t)'/> title='Edit topic (Shortcut: t)'/>
</div> </div>
<div ui:field='form' style='display: none' aria-hidden='true'> <div ui:field='form' style='display: none' aria-hidden='true'>

View File

@@ -22,8 +22,8 @@ import net.codemirror.lib.LineCharacter;
class EditIterator { class EditIterator {
private final JsArrayString lines; private final JsArrayString lines;
private final int startLine; private final int startLine;
private int currLineIndex; private int line;
private int currLineOffset; private int pos;
EditIterator(JsArrayString lineArray, int start) { EditIterator(JsArrayString lineArray, int start) {
lines = lineArray; lines = lineArray;
@@ -31,27 +31,44 @@ class EditIterator {
} }
LineCharacter advance(int numOfChar) { LineCharacter advance(int numOfChar) {
while (currLineIndex < lines.length()) { numOfChar = adjustForNegativeDelta(numOfChar);
int lengthWithNewline =
lines.get(currLineIndex).length() - currLineOffset + 1; while (line < lines.length()) {
if (numOfChar < lengthWithNewline) { int len = lines.get(line).length() - pos + 1; // + 1 for LF
if (numOfChar < len) {
LineCharacter at = LineCharacter.create( LineCharacter at = LineCharacter.create(
startLine + currLineIndex, startLine + line,
numOfChar + currLineOffset); numOfChar + pos);
currLineOffset += numOfChar; pos += numOfChar;
return at; return at;
} }
numOfChar -= lengthWithNewline;
advanceLine(); numOfChar -= len;
line++;
pos = 0;
if (numOfChar == 0) { if (numOfChar == 0) {
return LineCharacter.create(startLine + currLineIndex, 0); return LineCharacter.create(startLine + line, 0);
} }
} }
throw new IllegalStateException("EditIterator index out of bound");
throw new IllegalStateException("EditIterator index out of bounds");
} }
private void advanceLine() { private int adjustForNegativeDelta(int n) {
currLineIndex++; while (n < 0) {
currLineOffset = 0; if (-n <= pos) {
pos += n;
return 0;
}
n += pos;
line--;
if (line < 0) {
throw new IllegalStateException("EditIterator index out of bounds");
}
pos = lines.get(line).length() + 1;
}
return n;
} }
} }

View File

@@ -44,6 +44,13 @@ public class EditIteratorTest extends GwtTest {
lines.push("3rd"); lines.push("3rd");
} }
@Test
public void testNegativeAdvance() {
EditIterator i = new EditIterator(lines, 0);
assertLineChsEqual(LineCharacter.create(1, 1), i.advance(5));
assertLineChsEqual(LineCharacter.create(0, 3), i.advance(-2));
}
@Test @Test
public void testNoAdvance() { public void testNoAdvance() {
EditIterator iter = new EditIterator(lines, 0); EditIterator iter = new EditIterator(lines, 0);

View File

@@ -1801,7 +1801,7 @@ public class ReceiveCommits {
for (final Ref r : rp.getRepository().getRefDatabase() for (final Ref r : rp.getRepository().getRefDatabase()
.getRefs("refs/changes").values()) { .getRefs("refs/changes").values()) {
if (r.getObjectId().equals(inputCommand.getNewId())) { if (r.getObjectId().equals(newCommit)) {
reject(inputCommand, "commit already exists (in the project)"); reject(inputCommand, "commit already exists (in the project)");
return false; return false;
} }

View File

@@ -65,10 +65,11 @@ import org.apache.sshd.common.forward.TcpipServerChannel;
import org.apache.sshd.common.future.CloseFuture; import org.apache.sshd.common.future.CloseFuture;
import org.apache.sshd.common.future.SshFutureListener; import org.apache.sshd.common.future.SshFutureListener;
import org.apache.sshd.common.io.IoAcceptor; import org.apache.sshd.common.io.IoAcceptor;
import org.apache.sshd.common.io.IoServiceFactory; import org.apache.sshd.common.io.IoServiceFactoryFactory;
import org.apache.sshd.common.io.IoSession; import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.io.mina.MinaServiceFactory; import org.apache.sshd.common.io.mina.MinaServiceFactoryFactory;
import org.apache.sshd.common.io.mina.MinaSession; import org.apache.sshd.common.io.mina.MinaSession;
import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory;
import org.apache.sshd.common.mac.HMACMD5; import org.apache.sshd.common.mac.HMACMD5;
import org.apache.sshd.common.mac.HMACMD596; import org.apache.sshd.common.mac.HMACMD596;
import org.apache.sshd.common.mac.HMACSHA1; import org.apache.sshd.common.mac.HMACSHA1;
@@ -188,8 +189,13 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
final String kerberosPrincipal = cfg.getString( final String kerberosPrincipal = cfg.getString(
"sshd", null, "kerberosPrincipal"); "sshd", null, "kerberosPrincipal");
System.setProperty(IoServiceFactory.class.getName(), SshSessionBackend backend = cfg.getEnum(
MinaServiceFactory.class.getName()); "sshd", null, "backend", SshSessionBackend.MINA);
System.setProperty(IoServiceFactoryFactory.class.getName(),
backend == SshSessionBackend.MINA
? MinaServiceFactoryFactory.class.getName()
: Nio2ServiceFactoryFactory.class.getName());
if (SecurityUtils.isBouncyCastleRegistered()) { if (SecurityUtils.isBouncyCastleRegistered()) {
initProviderBouncyCastle(); initProviderBouncyCastle();
@@ -284,8 +290,10 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
public synchronized void stop() { public synchronized void stop() {
if (acceptor != null) { if (acceptor != null) {
try { try {
acceptor.dispose(); acceptor.close(true).await();
log.info("Stopped Gerrit SSHD"); log.info("Stopped Gerrit SSHD");
} catch (InterruptedException e) {
log.warn("Exception caught while closing", e);
} finally { } finally {
acceptor = null; acceptor = null;
} }
@@ -571,6 +579,11 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
@Override @Override
public SshFile getFile(String file) { public SshFile getFile(String file) {
return null; return null;
}
@Override
public FileSystemView getNormalizedView() {
return null;
}}; }};
} }
}); });

View File

@@ -6,6 +6,15 @@ EXCLUDE = [
'META-INF/NOTICE', 'META-INF/NOTICE',
] ]
maven_jar(
name = 'sshd',
id = 'org.apache.sshd:sshd-core:0.11.0',
sha1 = '450da44553c98805ca6bb5709cad54df4acb802a',
license = 'Apache2.0',
deps = [':core'],
exclude = EXCLUDE,
)
maven_jar( maven_jar(
name = 'core', name = 'core',
id = 'org.apache.mina:mina-core:2.0.7', id = 'org.apache.mina:mina-core:2.0.7',
@@ -13,13 +22,3 @@ maven_jar(
license = 'Apache2.0', license = 'Apache2.0',
exclude = EXCLUDE, exclude = EXCLUDE,
) )
maven_jar(
name = 'sshd',
id = 'org.apache.sshd:sshd-core:0.9.0.201311081',
sha1 = '38f7ac8602e70fa05fdc6147d204198e9cefe5bc',
license = 'Apache2.0',
deps = [':core'],
exclude = EXCLUDE,
repository = GERRIT,
)