Skip to content

Commit d1fd537

Browse files
authored
[JENKINS-75465] (Recreate) Delete RunIdMigrator as it has been 10 years since this migration (#10521)
1 parent 5e36565 commit d1fd537

File tree

18 files changed

+12
-888
lines changed

18 files changed

+12
-888
lines changed

core/src/main/java/hudson/model/Job.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
import jenkins.model.ModelObjectWithChildren;
9898
import jenkins.model.PeepholePermalink;
9999
import jenkins.model.ProjectNamingStrategy;
100-
import jenkins.model.RunIdMigrator;
101100
import jenkins.model.lazy.LazyBuildMixIn;
102101
import jenkins.scm.RunWithSCM;
103102
import jenkins.security.HexStringConfidentialKey;
@@ -192,10 +191,6 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
192191
// this should have been DescribableList but now it's too late
193192
protected CopyOnWriteList<JobProperty<? super JobT>> properties = new CopyOnWriteList<>();
194193

195-
@Restricted(NoExternalUse.class)
196-
@SuppressFBWarnings(value = "PA_PUBLIC_PRIMITIVE_ATTRIBUTE", justification = "Preserve API compatibility")
197-
public transient RunIdMigrator runIdMigrator;
198-
199194
protected Job(ItemGroup parent, String name) {
200195
super(parent, name);
201196
}
@@ -206,20 +201,19 @@ public synchronized void save() throws IOException {
206201
holdOffBuildUntilSave = holdOffBuildUntilUserSave;
207202
}
208203

209-
@Override public void onCreatedFromScratch() {
210-
super.onCreatedFromScratch();
211-
runIdMigrator = new RunIdMigrator();
212-
runIdMigrator.created(getBuildDir());
213-
}
214-
215204
@Override
216205
public void onLoad(ItemGroup<? extends Item> parent, String name)
217206
throws IOException {
218207
super.onLoad(parent, name);
219208

220-
File buildDir = getBuildDir();
221-
runIdMigrator = new RunIdMigrator();
222-
runIdMigrator.migrate(buildDir, Jenkins.get().getRootDir());
209+
// see https://github.com/jenkinsci/jenkins/pull/10456#issuecomment-2748112449
210+
// This code can be deleted after several Jenkins releases,
211+
// when it is likely that everyone is running a version equal or higher to this version.
212+
var buildDirPath = getBuildDir().toPath();
213+
if (Files.deleteIfExists(buildDirPath.resolve("legacyIds"))) {
214+
LOGGER.info("Deleting legacyIds file in " + buildDirPath + ". See https://issues.jenkins"
215+
+ ".io/browse/JENKINS-75465 for more information.");
216+
}
223217

224218
TextFile f = getNextBuildNumberFile();
225219
if (f.exists()) {

core/src/main/java/hudson/model/RunMap.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@
4545
import java.util.SortedMap;
4646
import java.util.logging.Level;
4747
import java.util.logging.Logger;
48-
import jenkins.model.RunIdMigrator;
4948
import jenkins.model.lazy.AbstractLazyLoadRunMap;
5049
import jenkins.model.lazy.BuildReference;
51-
import jenkins.model.lazy.LazyBuildMixIn;
5250
import org.kohsuke.accmod.Restricted;
5351
import org.kohsuke.accmod.restrictions.NoExternalUse;
5452

@@ -72,10 +70,6 @@ public final class RunMap<R extends Run<?, R>> extends AbstractLazyLoadRunMap<R>
7270

7371
private Constructor<R> cons;
7472

75-
/** Normally overwritten by {@link LazyBuildMixIn#onLoad} or {@link LazyBuildMixIn#onCreatedFromScratch}, in turn created during {@link Job#onLoad}. */
76-
@Restricted(NoExternalUse.class)
77-
public RunIdMigrator runIdMigrator = new RunIdMigrator();
78-
7973
// TODO: before first complete build
8074
// patch up next/previous build link
8175

@@ -156,7 +150,6 @@ public void remove() {
156150
@Override
157151
public boolean removeValue(R run) {
158152
run.dropLinks();
159-
runIdMigrator.delete(dir, run.getId());
160153
return super.removeValue(run);
161154
}
162155

@@ -227,14 +220,13 @@ public R put(R r) {
227220
return super._put(r);
228221
}
229222

223+
@CheckForNull
230224
@Override public R getById(String id) {
231-
int n;
232225
try {
233-
n = Integer.parseInt(id);
234-
} catch (NumberFormatException x) {
235-
n = runIdMigrator.findNumber(id);
226+
return getByNumber(Integer.parseInt(id));
227+
} catch (NumberFormatException e) { // see https://issues.jenkins.io/browse/JENKINS-75476
228+
return null;
236229
}
237-
return getByNumber(n);
238230
}
239231

240232
/**

core/src/main/java/jenkins/model/RunIdMigrator.java

Lines changed: 0 additions & 271 deletions
This file was deleted.

core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import java.util.Objects;
5050
import java.util.logging.Level;
5151
import java.util.logging.Logger;
52-
import jenkins.model.RunIdMigrator;
5352
import org.kohsuke.accmod.Restricted;
5453
import org.kohsuke.accmod.restrictions.DoNotUse;
5554

@@ -147,9 +146,6 @@ public RunT create(File dir) throws IOException {
147146
return loadBuild(dir);
148147
}
149148
});
150-
RunIdMigrator runIdMigrator = asJob().runIdMigrator;
151-
assert runIdMigrator != null;
152-
r.runIdMigrator = runIdMigrator;
153149
return r;
154150
}
155151

0 commit comments

Comments
 (0)