From a0937f7c285fbb6a8849b2155dc29e38f4918d86 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Fri, 5 Apr 2019 22:33:53 +0200 Subject: [PATCH] #977 - Simplified recreation of LinkBuilderSupport. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LinkBuilderSupport's constructor now obtains a UriComponentsBuilder in a less complicated way. Benchmarks before: Benchmark Mode Cnt Score Error Units ControllerLinkBuilderBenchmark.simpleLinkCreation thrpt 20 40,462 ± 1,572 ops/s Benchmarks after: Benchmark Mode Cnt Score Error Units ControllerLinkBuilderBenchmark.simpleLinkCreation thrpt 20 41,158 ± 0,624 ops/s --- .../hateoas/server/core/LinkBuilderSupport.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/springframework/hateoas/server/core/LinkBuilderSupport.java b/src/main/java/org/springframework/hateoas/server/core/LinkBuilderSupport.java index a7276c52..9b508a48 100644 --- a/src/main/java/org/springframework/hateoas/server/core/LinkBuilderSupport.java +++ b/src/main/java/org/springframework/hateoas/server/core/LinkBuilderSupport.java @@ -63,7 +63,7 @@ public abstract class LinkBuilderSupport implements LinkB protected LinkBuilderSupport(UriComponentsBuilder builder, List affordances) { - Assert.notNull(builder, "UriComponents must not be null!"); + Assert.notNull(builder, "UriComponentsBuilder must not be null!"); Assert.notNull(affordances, "Affordances must not be null!"); this.builder = builder.cloneBuilder(); @@ -72,12 +72,10 @@ public abstract class LinkBuilderSupport implements LinkB protected LinkBuilderSupport(UriComponents components, List affordances) { - String uriString = components.toUriString(); - UriComponentsBuilder builder = uriString.isEmpty() // - ? UriComponentsBuilder.fromUri(components.toUri()) // - : UriComponentsBuilder.fromUriString(uriString); + Assert.notNull(components, "UriComponents must not be null!"); + Assert.notNull(affordances, "Affordances must not be null!"); - this.builder = builder; + this.builder = UriComponentsBuilder.fromUriString(components.toUriString()); this.affordances = affordances; }