package handson;

import io.sphere.sdk.client.SphereClient;
import io.sphere.sdk.client.SphereClientConfig;
import io.sphere.sdk.client.SphereClientFactory;
import io.sphere.sdk.products.queries.ProductProjectionQuery;

import java.io.IOException;
import java.util.Properties;

public class Main {
    public static void main(String[] args) throws IOException {
        final Properties prop = loadCommercetoolsPlatformProperties();
        final String projectKey = prop.getProperty("projectKey");
        final String clientId = prop.getProperty("clientId");
        final String clientSecret = prop.getProperty("clientSecret");
        final SphereClientConfig clientConfig = SphereClientConfig.of(projectKey, clientId, clientSecret);
        try(final SphereClient client = SphereClientFactory.of().createClient(clientConfig)) {
            System.err.println(client.execute(ProductProjectionQuery.ofCurrent()).toCompletableFuture().join());
        }
    }

    private static Properties loadCommercetoolsPlatformProperties() throws IOException {
        final Properties prop = new Properties();
        prop.load(Main.class.getClassLoader().getResourceAsStream("dev.properties"));
        return prop;
    }
}

@@ -11,16 +11,66 @@
 ndson;%0A%0A
+import io.sphere.sdk.client.BlockingSphereClient;%0A
 import i
@@ -291,16 +291,43 @@
 eption;%0A
+import java.time.Duration;%0A
 import j
@@ -444,373 +444,362 @@
     
+try(
 final 
-Properties prop = loadCommercetoolsPlatformProperties();%0A        final String projectKey = prop.getProperty(%22projectKey%22);%0A        final String clientId = prop.getProperty(%22clientId%22);%0A        final String clientSecret = prop.getProperty(%22clientSecret%22);%0A        final SphereClientConfig clientConfig = SphereClientConfig.of(projectKey, clientId, clientSecret
+SphereClient client = createSphereClient()) %7B%0A            System.err.println(client.execute(ProductProjectionQuery.ofCurrent()).toCompletableFuture().join());%0A        %7D%0A    %7D%0A%0A    private static BlockingSphereClient createSphereClient() throws IOException %7B%0A        final SphereClientConfig clientConfig = loadCommercetoolsPlatformClientConfig(
 );%0A 
@@ -797,36 +797,32 @@
 nfig();%0A        
-try(
 final SphereClie
@@ -884,19 +884,17 @@
 tConfig)
-) %7B
+;
 %0A       
@@ -898,122 +898,70 @@
     
-    System.err.println(client.execute(ProductProjectionQuery.ofCurrent()).toCompletableFuture().join());%0A        %7D
+return BlockingSphereClient.of(client, Duration.ofMinutes(1));
 %0A   
@@ -983,26 +983,34 @@
  static 
-Properties
+SphereClientConfig
  loadCom
@@ -1027,26 +1027,28 @@
 Platform
-Properties
+ClientConfig
 () throw
@@ -1211,19 +1211,270 @@
     
-return prop
+final String projectKey = prop.getProperty(%22projectKey%22);%0A        final String clientId = prop.getProperty(%22clientId%22);%0A        final String clientSecret = prop.getProperty(%22clientSecret%22);%0A        return SphereClientConfig.of(projectKey, clientId, clientSecret)
 ;%0A  

Move client creation to another method and use blocking client instead