@@ -186,10 +186,14 @@ public static AffinityLock acquireLock(boolean bind) {
186186 * @return A handle for an affinity lock.
187187 */
188188 public static AffinityLock acquireLock (int cpuId ) {
189+ checkCpuId (cpuId );
190+ return acquireLock (true , cpuId , AffinityStrategies .ANY );
191+ }
192+
193+ private static void checkCpuId (int cpuId ) {
189194 if (cpuId < 0 || cpuId >= PROCESSORS ) {
190- throw new IllegalArgumentException ("cpuId must be between 0 and " + ( PROCESSORS - 1 ) + ": " + cpuId );
195+ LOGGER . warn ("cpuId must be between 0 and {}: {}" , PROCESSORS - 1 , cpuId );
191196 }
192- return acquireLock (true , cpuId , AffinityStrategies .ANY );
193197 }
194198
195199 /**
@@ -203,9 +207,7 @@ public static AffinityLock acquireLock(int cpuId) {
203207 */
204208 public static AffinityLock acquireLock (int [] cpus ) {
205209 for (int cpu : cpus ) {
206- if (cpu < 0 || cpu >= PROCESSORS ) {
207- throw new IllegalArgumentException ("cpuId must be between 0 and " + (PROCESSORS - 1 ) + ": " + cpu );
208- }
210+ checkCpuId (cpu );
209211 AffinityLock lock = tryAcquireLock (true , cpu );
210212 if (lock != null ) {
211213 LOGGER .info ("Acquired lock on CPU {}" , cpu );
@@ -265,7 +267,7 @@ public static AffinityLock acquireLock(String desc) {
265267
266268 } else if (desc .startsWith ("csv:" )) {
267269 String content = desc .substring (4 );
268- int [] cpus = Arrays .asList (content .split ("," )). stream ( )
270+ int [] cpus = Arrays .stream (content .split ("," ))
269271 .map (String ::trim )
270272 .mapToInt (Integer ::parseInt ).toArray ();
271273
0 commit comments