Skip to content

Commit

Permalink
scala 改回11.7版本,同步块修改
Browse files Browse the repository at this point in the history
  • Loading branch information
lihuimin authored and lihuimin committed Nov 28, 2017
1 parent b70b679 commit 9f1ded9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions dapeng-code-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java-version>1.8</java-version>
<scala.version>2.12.2</scala.version>
<scala.binary.version>2.12.2</scala.binary.version>
<scala.version>2.11.7</scala.version>
<scala.binary.version>2.11.7</scala.binary.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ private synchronized Channel connect(String host, int port) throws Exception {
synchronized (byteBufs) {
byteBufs[0] = msg;

byteBufs.notify();
byteBufs = caches.get(String.valueOf(seqid));
// if peer wait byebuffs != null if peer out of synchornized, bytebuffs == null
if(byteBufs != null) {
byteBufs.notify();
}
}
}
};
Expand All @@ -158,24 +162,20 @@ public ByteBuf send(int seqid, ByteBuf request) throws Exception {

caches.put(String.valueOf(seqid), byteBufs);

try {
channel.writeAndFlush(request);
synchronized (byteBufs) {
try {
channel.writeAndFlush(request);

//等待返回结果,soaClientHandler会将结果写入caches并释放锁,此时返回
synchronized (byteBufs) {
//等待返回结果,soaClientHandler会将结果写入caches并释放锁,此时返回
if (byteBufs[0] != null)
return byteBufs[0];

try {
byteBufs.wait(50000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
byteBufs.wait(50000);

return byteBufs[0];
} finally {
caches.remove(String.valueOf(seqid));
return byteBufs[0];
} finally {
caches.remove(String.valueOf(seqid));
}
}
}

Expand Down

0 comments on commit 9f1ded9

Please sign in to comment.