File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed
polaris-sync-commons/src/main/java/cn/polarismesh/polaris/sync/common/rest
polaris-sync-registry-core/src/main/java/cn/polarismesh/polaris/sync/registry/tasks Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 2020import java .time .Duration ;
2121import java .util .List ;
2222import java .util .Random ;
23+ import java .util .concurrent .ThreadLocalRandom ;
2324import org .springframework .boot .web .client .RestTemplateBuilder ;
2425import org .springframework .http .HttpEntity ;
2526import org .springframework .http .HttpMethod ;
@@ -46,9 +47,8 @@ public static String pickAddress(List<String> addresses) {
4647 if (addresses .size () == 1 ) {
4748 return addresses .get (0 );
4849 }
49- Random random = new Random ();
50- int i = random .nextInt ();
51- return addresses .get (i % addresses .size ());
50+ int i = ThreadLocalRandom .current ().nextInt (addresses .size ());
51+ return addresses .get (i );
5252 }
5353
5454 public <T > RestResponse <T > curlRemoteEndpoint (String url , HttpMethod method ,
Original file line number Diff line number Diff line change 2626import cn .polarismesh .polaris .sync .registry .utils .ConfigUtils ;
2727import com .tencent .polaris .client .pb .ResponseProto .DiscoverResponse ;
2828import com .tencent .polaris .client .pb .ServiceProto .Instance ;
29+ import java .io .ByteArrayInputStream ;
30+ import java .io .PrintWriter ;
31+ import java .io .StringWriter ;
2932import java .util .Collection ;
3033import java .util .HashMap ;
3134import java .util .List ;
@@ -86,7 +89,10 @@ public void run() {
8689 }
8790 }
8891 } catch (Throwable e ) {
89- LOG .error ("[Core] pull task(source {}) encounter exception" , source .getName (), e );
92+ StringWriter sw = new StringWriter ();
93+ PrintWriter pw = new PrintWriter (sw );
94+ e .printStackTrace (pw );
95+ LOG .error ("[Core] pull task(source {}) encounter exception {}" , source .getName (), sw );
9096 }
9197 }
9298
Original file line number Diff line number Diff line change 4646 </scm >
4747
4848 <properties >
49- <revision >0.2.0-alpha.1 </revision >
49+ <revision >0.2.0-alpha.2 </revision >
5050 <timestamp >${maven.build.timestamp}</timestamp >
5151 <!-- Spring Cloud -->
5252 <spring .cloud.version>2021.0.3</spring .cloud.version>
You can’t perform that action at this time.
0 commit comments