Skip to content

Commit

Permalink
[FIXED JENKINS-11251]
Browse files Browse the repository at this point in the history
The actual meat of the change is in remoting.
(cherry picked from commit f49d625)

Conflicts:

	changelog.html
  • Loading branch information
kohsuke authored and vjuranek committed Jul 8, 2012
1 parent 75dc1e1 commit 6b495ce
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 3 additions & 1 deletion changelog.html
Expand Up @@ -55,7 +55,9 @@
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=>
<li class=bug>
Fixed a synchronization problem between master/slave data communication.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-11251">issue 11251</a>)
</ul>
</div><!--=TRUNK-END=-->

Expand Down
18 changes: 17 additions & 1 deletion core/src/main/java/hudson/FilePath.java
Expand Up @@ -1453,6 +1453,16 @@ public String readToString() throws IOException {
* Writes to this file.
* If this file already exists, it will be overwritten.
* If the directory doesn't exist, it will be created.
*
* <P>
* I/O operation to remote {@link FilePath} happens asynchronously, meaning write operations to the returned
* {@link OutputStream} will return without receiving a confirmation from the remote that the write happened.
* I/O operations also happens asynchronously from the {@link Channel#call(Callable)} operations, so if
* you write to a remote file and then execute {@link Channel#call(Callable)} and try to access the newly copied
* file, it might not be fully written yet.
*
* <p>
*
*/
public OutputStream write() throws IOException, InterruptedException {
if(channel==null) {
Expand Down Expand Up @@ -1593,10 +1603,16 @@ public Void invoke(File f, VirtualChannel channel) throws IOException {
}
});

// make sure the write fully happens before we return.
// make sure the writes fully got delivered to 'os' before we return.
// this is needed because I/O operation is asynchronous
syncIO();
}

/**
* With fix to JENKINS-11251 (remoting 2.15), this is no longer necessary.
* But I'm keeping it for a while so that users who manually deploy slave.jar has time to deploy new version
* before this goes away.
*/
private void syncIO() throws InterruptedException {
try {
if (channel!=null)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -189,7 +189,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>remoting</artifactId>
<version>2.13</version>
<version>2.16</version>
</dependency>

<dependency>
Expand Down

0 comments on commit 6b495ce

Please sign in to comment.