Skip to content
Browse files

[JENKINS-28913] correctly regenerate the ID.

If the id was not generated correctly then delete the file before
regenerating the ID, otherwise the new ID will never be created.
  • Loading branch information
jtnord committed Jun 15, 2015
1 parent f79e4cd commit aa7d348416c542b4fce20ca0d29822ff42bfa9f8
@@ -64,7 +64,8 @@ public String get(PersistenceRoot object) {
try {
String str = FileUtils.readFileToString(f, StandardCharsets.UTF_8);
if (str.length() == 0) {
// regenerate it.
// regenerate it JENKINS-28913
str = FileUtils.readFileToString(f, StandardCharsets.UTF_8);
@@ -4,18 +4,21 @@
import hudson.model.AbstractProject;
import hudson.model.Project;

import java.util.HashSet;
import java.util.Set;

import org.hamcrest.core.Is;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

import com.cloudbees.hudson.plugins.folder.Folder;

import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
@@ -81,4 +84,19 @@ public void uniqueness() throws Exception {
assertThat(ids, hasSize(200));

public void correctJenkins28913() throws Exception {
Project<?, ?> p = jenkinsRule.createFreeStyleProject();
File f = new File(p.getRootDir(), "unique-id.txt");
assertThat(f.exists(), is(false));

assertThat("no Id yet made", IdStore.getId(p), nullValue());

assertThat(f.createNewFile(), is(true));

String id = IdStore.getId(p);
assertThat("id file was empty should have been re-gernerated", id.length(), greaterThan(20));

0 comments on commit aa7d348

Please sign in to comment.
You can’t perform that action at this time.