Browse Source

Solution for the Starteam disconnect bug

PR: 24110
Submitted by: Steve Cohen (scohen at apache dot org)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275572 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 22 years ago
parent
commit
12c5bbbb6d
3 changed files with 44 additions and 20 deletions
  1. +26
    -18
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamLabel.java
  2. +15
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamTask.java
  3. +3
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java

+ 26
- 18
src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamLabel.java View File

@@ -76,6 +76,7 @@ import org.apache.tools.ant.BuildException;
*
* @author Christopher Charlier, ThoughtWorks, Inc. 2001
* @author <a href="mailto:jcyip@thoughtworks.com">Jason Yip</a>
* @author <a href="mailto:scohen@apache.org">Steve Cohen</a>
* @see <A HREF="http://www.starbase.com/">StarBase Web Site</A>
*
* @ant.task name="stlabel" category="scm"
@@ -179,25 +180,32 @@ public class StarTeamLabel extends StarTeamTask {
+ "both specified. A revision label cannot be a build label.");
}

View snapshot = openView();

// Create the new label and update the repository

if (this.revisionlabel) {
new Label(snapshot, this.labelName, this.description).update();
log("Created Revision Label " + this.labelName);
} else if (null != lastBuild) {
new Label(snapshot, this.labelName, this.description, this.lastBuild,
this.buildlabel).update();
log("Created View Label ("
+ (this.buildlabel ? "" : "non-") + "build) " + this.labelName
+ " as of " + this.lastBuild.toString());
} else {
new Label(snapshot, this.labelName, this.description,
this.buildlabel).update();
log("Created View Label ("
+ (this.buildlabel ? "" : "non-") + "build) " + this.labelName);
try {
View snapshot = openView();

// Create the new label and update the repository

if (this.revisionlabel) {
new Label(snapshot, this.labelName, this.description).update();
log("Created Revision Label " + this.labelName);
} else if (null != lastBuild) {
new Label(snapshot, this.labelName, this.description, this.lastBuild,
this.buildlabel).update();
log("Created View Label ("
+ (this.buildlabel ? "" : "non-") + "build) " + this.labelName
+ " as of " + this.lastBuild.toString());
} else {
new Label(snapshot, this.labelName, this.description,
this.buildlabel).update();
log("Created View Label ("
+ (this.buildlabel ? "" : "non-") + "build) " + this.labelName);
}
} catch (Exception e) {
throw new BuildException(e);
} finally {
disconnectFromServer();
}

}

/**


+ 15
- 1
src/main/org/apache/tools/ant/taskdefs/optional/starteam/StarTeamTask.java View File

@@ -117,7 +117,7 @@ public abstract class StarTeamTask extends Task {

private void logStarteamVersion() {
log("StarTeam version: "
+ BuildNumber.getDisplayString(), Project.MSG_DEBUG);
+ BuildNumber.getDisplayString(), Project.MSG_VERBOSE);
}


@@ -317,6 +317,18 @@ public abstract class StarTeamTask extends Task {
return this.server;
}

/**
* disconnects from the StarTeam server. Should be called from the
* finally clause of every StarTeamTask-based execute method.
*/
protected final void disconnectFromServer() {
if (null != this.server) {
this.server.disconnect();
log("successful disconnect from StarTeam Server " + servername,
Project.MSG_VERBOSE);
}
}

/**
* returns a list of TypeNames known to the server.
*
@@ -362,6 +374,8 @@ public abstract class StarTeamTask extends Task {
}

View snapshot = createSnapshotView(view);
log("Connected to StarTeam view " + getURL(),
Project.MSG_VERBOSE);
this.server = snapshot.getServer();
return snapshot;
}


+ 3
- 1
src/main/org/apache/tools/ant/taskdefs/optional/starteam/TreeBasedTask.java View File

@@ -723,6 +723,8 @@ public abstract class TreeBasedTask extends StarTeamTask {

} catch (Exception e) {
throw new BuildException(e);
} finally {
disconnectFromServer();
}
}

@@ -735,7 +737,7 @@ public abstract class TreeBasedTask extends StarTeamTask {
if (!stLabel.isRevisionLabel() && !stLabel.isViewLabel()) {
throw new BuildException("Unexpected label type.");
}
log("using label " + stLabel.getName(), Project.MSG_DEBUG);
log("using label " + stLabel.getName(), Project.MSG_VERBOSE);
this.labelInUse = stLabel;
return;
}


Loading…
Cancel
Save