KEYCLOAK-2687 ZIPException during import big number of users

This commit is contained in:
mposolda 2016-03-21 11:19:39 +01:00
parent e56759a6c0
commit 4193856fbb
2 changed files with 9 additions and 3 deletions

View file

@ -561,7 +561,7 @@ public class Base64
while( raw.hasRemaining() ){ while( raw.hasRemaining() ){
int rem = Math.min(3,raw.remaining()); int rem = Math.min(3,raw.remaining());
raw.get(raw3,0,rem); raw.get(raw3,0,rem);
Base64.encode3to4(enc4, raw3, rem, Base64.NO_OPTIONS ); Base64.encode3to4(enc4, raw3, rem, Base64.NO_OPTIONS);
encoded.put(enc4); encoded.put(enc4);
} // end input remaining } // end input remaining
} }
@ -1282,7 +1282,12 @@ public class Base64
} // end try } // end try
catch( java.io.IOException e ) { 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 // Just return originally-decoded bytes
} // end catch } // end catch
finally { finally {

View file

@ -133,12 +133,13 @@ public class DirImportProvider implements ImportProvider {
if (realmImported.get()) { if (realmImported.get()) {
// Import users // Import users
for (File userFile : userFiles) { for (final File userFile : userFiles) {
final FileInputStream fis = new FileInputStream(userFile); final FileInputStream fis = new FileInputStream(userFile);
KeycloakModelUtils.runJobInTransaction(factory, new ExportImportSessionTask() { KeycloakModelUtils.runJobInTransaction(factory, new ExportImportSessionTask() {
@Override @Override
protected void runExportImportTask(KeycloakSession session) throws IOException { protected void runExportImportTask(KeycloakSession session) throws IOException {
ImportUtils.importUsersFromStream(session, realmName, JsonSerialization.mapper, fis); ImportUtils.importUsersFromStream(session, realmName, JsonSerialization.mapper, fis);
logger.infof("Imported users from %s", userFile.getAbsolutePath());
} }
}); });
} }