From 83579cfbdfbf79d9454a1cc83f49a644c3ce68c0 Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Thu, 5 Aug 2021 22:14:05 +0200 Subject: [PATCH] Extract charset name as constant in JdbcExecutionContextDao --- .../core/repository/dao/JdbcExecutionContextDao.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java index 1e1274939..f2b28c191 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcExecutionContextDao.java @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 the original author or authors. + * Copyright 2006-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -74,6 +74,8 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem private static final String UPDATE_STEP_EXECUTION_CONTEXT = "UPDATE %PREFIX%STEP_EXECUTION_CONTEXT " + "SET SHORT_CONTEXT = ?, SERIALIZED_CONTEXT = ? " + "WHERE STEP_EXECUTION_ID = ?"; + private static final String CHARSET_NAME = "ISO-8859-1"; + private static final int DEFAULT_MAX_VARCHAR_LENGTH = 2500; private int shortContextLength = DEFAULT_MAX_VARCHAR_LENGTH; @@ -300,7 +302,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem try { serializer.serialize(m, out); - results = new String(out.toByteArray(), "ISO-8859-1"); + results = new String(out.toByteArray(), CHARSET_NAME); } catch (IOException ioe) { throw new IllegalArgumentException("Could not serialize the execution context", ioe); @@ -321,7 +323,7 @@ public class JdbcExecutionContextDao extends AbstractJdbcBatchMetadataDao implem Map map; try { - ByteArrayInputStream in = new ByteArrayInputStream(serializedContext.getBytes("ISO-8859-1")); + ByteArrayInputStream in = new ByteArrayInputStream(serializedContext.getBytes(CHARSET_NAME)); map = serializer.deserialize(in); } catch (IOException ioe) {