Skip to content

Commit 75f210a

Browse files
committed
Merge branch '2.1.x'
Closes spring-projectsgh-18906
2 parents 1429344 + 8d3df1b commit 75f210a

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/artifactory/ArtifactoryService.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.springframework.http.RequestEntity;
3131
import org.springframework.http.ResponseEntity;
3232
import org.springframework.stereotype.Component;
33+
import org.springframework.util.StringUtils;
3334
import org.springframework.web.client.HttpClientErrorException;
3435
import org.springframework.web.client.RestTemplate;
3536

@@ -53,19 +54,18 @@ public class ArtifactoryService {
5354

5455
private final RestTemplate restTemplate;
5556

56-
private final ArtifactoryProperties artifactoryProperties;
57-
5857
private final BintrayService bintrayService;
5958

6059
private static final ConsoleLogger console = new ConsoleLogger();
6160

6261
public ArtifactoryService(RestTemplateBuilder builder, ArtifactoryProperties artifactoryProperties,
6362
BintrayService bintrayService) {
64-
this.artifactoryProperties = artifactoryProperties;
6563
this.bintrayService = bintrayService;
6664
String username = artifactoryProperties.getUsername();
6765
String password = artifactoryProperties.getPassword();
68-
builder = builder.basicAuthentication(username, password);
66+
if (StringUtils.hasLength(username)) {
67+
builder = builder.basicAuthentication(username, password);
68+
}
6969
this.restTemplate = builder.build();
7070
}
7171

ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/bintray/BintrayService.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.http.MediaType;
3232
import org.springframework.http.RequestEntity;
3333
import org.springframework.stereotype.Component;
34+
import org.springframework.util.StringUtils;
3435
import org.springframework.web.client.HttpClientErrorException;
3536
import org.springframework.web.client.RestTemplate;
3637

@@ -65,7 +66,9 @@ public BintrayService(RestTemplateBuilder builder, BintrayProperties bintrayProp
6566
this.sonatypeService = sonatypeService;
6667
String username = bintrayProperties.getUsername();
6768
String apiKey = bintrayProperties.getApiKey();
68-
builder = builder.basicAuthentication(username, apiKey);
69+
if (StringUtils.hasLength(username)) {
70+
builder = builder.basicAuthentication(username, apiKey);
71+
}
6972
this.restTemplate = builder.build();
7073
}
7174

ci/images/releasescripts/src/main/java/io/spring/concourse/releasescripts/sonatype/SonatypeService.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.http.HttpStatus;
2424
import org.springframework.http.ResponseEntity;
2525
import org.springframework.stereotype.Component;
26+
import org.springframework.util.StringUtils;
2627
import org.springframework.web.client.HttpClientErrorException;
2728
import org.springframework.web.client.RestTemplate;
2829

@@ -38,15 +39,14 @@ public class SonatypeService {
3839

3940
private final RestTemplate restTemplate;
4041

41-
private final SonatypeProperties sonatypeProperties;
42-
4342
private static final ConsoleLogger console = new ConsoleLogger();
4443

4544
public SonatypeService(RestTemplateBuilder builder, SonatypeProperties sonatypeProperties) {
46-
this.sonatypeProperties = sonatypeProperties;
4745
String username = sonatypeProperties.getUserToken();
48-
String apiKey = sonatypeProperties.getPasswordToken();
49-
builder = builder.basicAuthentication(username, apiKey);
46+
String password = sonatypeProperties.getPasswordToken();
47+
if (StringUtils.hasLength(username)) {
48+
builder = builder.basicAuthentication(username, password);
49+
}
5050
this.restTemplate = builder.build();
5151
}
5252

0 commit comments

Comments
 (0)