From 4193856fbb51f7b8888f06cf6d153626581beb7a Mon Sep 17 00:00:00 2001 From: mposolda Date: Mon, 21 Mar 2016 11:19:39 +0100 Subject: [PATCH] KEYCLOAK-2687 ZIPException during import big number of users --- .../src/main/java/org/keycloak/common/util/Base64.java | 9 +++++++-- .../org/keycloak/exportimport/dir/DirImportProvider.java | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/org/keycloak/common/util/Base64.java b/common/src/main/java/org/keycloak/common/util/Base64.java index 163bf2eead..b90f1b29c0 100644 --- a/common/src/main/java/org/keycloak/common/util/Base64.java +++ b/common/src/main/java/org/keycloak/common/util/Base64.java @@ -561,7 +561,7 @@ public class Base64 while( raw.hasRemaining() ){ int rem = Math.min(3,raw.remaining()); raw.get(raw3,0,rem); - Base64.encode3to4(enc4, raw3, rem, Base64.NO_OPTIONS ); + Base64.encode3to4(enc4, raw3, rem, Base64.NO_OPTIONS); encoded.put(enc4); } // end input remaining } @@ -1282,7 +1282,12 @@ public class Base64 } // end try catch( java.io.IOException e ) { - e.printStackTrace(); + if (e.getMessage().equals("Unsupported compression method")) { + System.out.println("Base64 decoding: Ignoring GZIP header and just returning originally-decoded bytes."); // Better to log as debug, but jboss logging not available in the module :/ + } else { + e.printStackTrace(); + } + // Just return originally-decoded bytes } // end catch finally { diff --git a/services/src/main/java/org/keycloak/exportimport/dir/DirImportProvider.java b/services/src/main/java/org/keycloak/exportimport/dir/DirImportProvider.java index 329b7297c3..391d9a68c4 100755 --- a/services/src/main/java/org/keycloak/exportimport/dir/DirImportProvider.java +++ b/services/src/main/java/org/keycloak/exportimport/dir/DirImportProvider.java @@ -133,12 +133,13 @@ public class DirImportProvider implements ImportProvider { if (realmImported.get()) { // Import users - for (File userFile : userFiles) { + for (final File userFile : userFiles) { final FileInputStream fis = new FileInputStream(userFile); KeycloakModelUtils.runJobInTransaction(factory, new ExportImportSessionTask() { @Override protected void runExportImportTask(KeycloakSession session) throws IOException { ImportUtils.importUsersFromStream(session, realmName, JsonSerialization.mapper, fis); + logger.infof("Imported users from %s", userFile.getAbsolutePath()); } }); }