IDEMPIERE-5456 - Msg wrong arguments number Format (#1537)

This commit is contained in:
Peter Takács 2022-10-21 04:33:47 +02:00 committed by GitHub
parent 495c9ef108
commit 978be7a956
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 10 deletions

View File

@ -30,7 +30,6 @@ import java.sql.SQLException;
import java.sql.SQLWarning; import java.sql.SQLWarning;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -583,8 +582,7 @@ public final class DB
String AD_Message = "DatabaseVersionError"; String AD_Message = "DatabaseVersionError";
// Code assumes Database version {0}, but Database has Version {1}. // Code assumes Database version {0}, but Database has Version {1}.
String msg = Msg.getMsg(ctx, AD_Message); // complete message String msg = Msg.getMsg(ctx, AD_Message, new Object[] {Adempiere.DB_VERSION, version}); // complete message
msg = MessageFormat.format(msg, new Object[] {Adempiere.DB_VERSION, version});
System.err.println(msg); System.err.println(msg);
return false; return false;
} // isDatabaseOK } // isDatabaseOK
@ -635,8 +633,7 @@ public final class DB
String AD_Message = "BuildVersionError"; String AD_Message = "BuildVersionError";
// The program assumes build version {0}, but database has build Version {1}. // The program assumes build version {0}, but database has build Version {1}.
String msg = Msg.getMsg(ctx, AD_Message); // complete message String msg = Msg.getMsg(ctx, AD_Message, new Object[] {buildClient, buildDatabase}); // complete message
msg = MessageFormat.format(msg, new Object[] {buildClient, buildDatabase});
if (! failOnBuild) { if (! failOnBuild) {
log.warning(msg); log.warning(msg);
return true; return true;

View File

@ -440,7 +440,7 @@ public final class Msg
String retStr = msg; String retStr = msg;
try try
{ {
retStr = MessageFormat.format(msg, args); // format string retStr = new MessageFormat(msg, Language.getLocale(ad_language)).format(args); // format string
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -1731,7 +1731,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
sb.append(origmsg); sb.append(origmsg);
} else { } else {
String adMessageQuot = Util.replace(adMessage.toString(), "'", "''"); String adMessageQuot = Util.replace(adMessage.toString(), "'", "''");
sb.append(MessageFormat.format(adMessageQuot, arguments)); sb.append(new MessageFormat(adMessageQuot, Env.getLanguage(Env.getCtx()).getLocale()).format(arguments));
} }
} }
else else

View File

@ -24,7 +24,6 @@
package org.adempiere.webui.panel; package org.adempiere.webui.panel;
import java.io.IOException; import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@ -662,8 +661,7 @@ public class LoginPanel extends Window implements EventListener<Event>
if (! Adempiere.DB_VERSION.equals(version)) { if (! Adempiere.DB_VERSION.equals(version)) {
String AD_Message = "DatabaseVersionError"; String AD_Message = "DatabaseVersionError";
// Code assumes Database version {0}, but Database has Version {1}. // Code assumes Database version {0}, but Database has Version {1}.
String msg = Msg.getMsg(ctx, AD_Message); // complete message String msg = Msg.getMsg(ctx, AD_Message, new Object[] {Adempiere.DB_VERSION, version}); // complete message
msg = MessageFormat.format(msg, new Object[] {Adempiere.DB_VERSION, version});
throw new ApplicationException(msg); throw new ApplicationException(msg);
} }