Support souhaité sur des erreurs constatée en log ayant provoqué un redé

Request description

Bonjour,
Je voudrais vous soumettre un soucis rencontré ce matin en production ayant conduit à un redémarrage de l’application.

Le problème au entre 06:48 et 07:10 le redémarrage.
La log est en PJ ici

downloaded-logs-20221201-092115.csv (932.7 KB)

mais je vous partage ici les exceptions les plus marquantes. Je ne sais pas si une de ces exceptions va vous parler et nous aider à nous orienter dans notre investigation.

Merci par avance

Dans l’ordre chronologique:

A 06:47 on a ce message:
06:47:09,008|GLOBAL|INFO|e[32m2022-12-01 06:47:09,005|SIMPLICITE|INFO||http://mla-api-6ff6c94c9-gccmk:8080||ICORED0001|public|com.simplicite.util.Grant|init||Info: public connected, session ID: E903D66ACF2C0523BAA3DA26C75FDD18, timeout: 5 min , user agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",2022-12-01T05:47:09.959529366Z

A 06:47
06:47:48,966|SIMPLICITE|INFO||http://mla-api-6ff6c94c9-gccmk:8080||ICORED0001|p109329|com.simplicite.util.Grant|init||Info : p109329 connected, session ID: 8888E325820BB685E61A0BCD39999884, timeout: 540 min , user agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",2022-12-01T05:47:49.963033094Z

On a ensuite ce bloc:

mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container**,INFO,“e[me[31m2022-12-01 06:48:31,257|SIMPLICITE|ERROR||http://mla-api-6ff6c94c9-gccmk:8080||ERROR|system|com.simplicite.util.engine.ScriptAgent|callMethod (customAuth)||Exception:null||null”**,2022-12-01T05:48:31.966769024Z

mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,“e[me[32m2022-12-01 06:48:31,217|SIMPLICITE|INFO||http://mla-api-6ff6c94c9-gccmk:8080||INFO|system|com.simplicite.util.engine.CoreCache|getClassLoader||Loaded dynamic JARs”,2022-12-01T05:48:31.966763002Z

mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,“e[m2022-12-01 06:48:31,276|GLOBAL|INFO|e[32m2022-12-01 06:48:31,217|SIMPLICITE|INFO||http://mla-api-6ff6c94c9-gccmk:8080||INFO|system|com.simplicite.util.engine.DynamicClassLoader|DynamicClassLoader||Instanciate DynamicClassLoader@606385e5”,2022-12-01T05:48:31.966733529Z

mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,“e[me[32m2022-12-01 06:48:18,956|SIMPLICITE|INFO||http://mla-api-6ff6c94c9-gccmk:8080||INFO|system|com.simplicite.util.engine.CronManager$CronDaemon|run||The CronDaemon has been interrupted.”,2022-12-01T05:48:18.965637204Z

Puis cette exception avec sa trace:
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO," at java.base/java.lang.Thread.run(Thread.java:833)“,2022-12-01T05:48:31.966863983Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)“,2022-12-01T05:48:31.966861288Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)“,2022-12-01T05:48:31.966858583Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)“,2022-12-01T05:48:31.966855914Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)“,2022-12-01T05:48:31.966853389Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789)“,2022-12-01T05:48:31.966850918Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)“,2022-12-01T05:48:31.966848504Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)“,2022-12-01T05:48:31.966846082Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)“,2022-12-01T05:48:31.966843654Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)“,2022-12-01T05:48:31.966840821Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)“,2022-12-01T05:48:31.966838327Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)“,2022-12-01T05:48:31.966835825Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)“,2022-12-01T05:48:31.966833267Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)“,2022-12-01T05:48:31.966830580Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at com.simplicite.tomcat.valves.APISessionValve.invoke(APISessionValve.java:242)“,2022-12-01T05:48:31.966817747Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)“,2022-12-01T05:48:31.966815202Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)“,2022-12-01T05:48:31.966812785Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:183)“,2022-12-01T05:48:31.966810279Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)“,2022-12-01T05:48:31.966807731Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)“,2022-12-01T05:48:31.966805219Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at com.simplicite.webapp.filters.AbstractFilter.doFilter(AbstractFilter.java:37)“,2022-12-01T05:48:31.966802124Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at com.simplicite.webapp.filters.AuthMethodFilter.doFilter(AuthMethodFilter.java:195)“,2022-12-01T05:48:31.966797895Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at com.simplicite.util.ScriptedPlatformHooks.customAuth(ScriptedPlatformHooks.java:149)“,2022-12-01T05:48:31.966795179Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at com.simplicite.util.engine.ScriptAgent.callMethod(ScriptAgent.java:591)“,2022-12-01T05:48:31.966792622Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at com.simplicite.util.engine.CoreCache.getClassInstance(CoreCache.java:5588)“,2022-12-01T05:48:31.966790163Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)“,2022-12-01T05:48:31.966787552Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)“,2022-12-01T05:48:31.966784629Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)“,2022-12-01T05:48:31.966781699Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)“,2022-12-01T05:48:31.966778236Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,” at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)",2022-12-01T05:48:31.966775367Z
mla-api,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,INFO,java.lang.ExceptionInInitializerError,2022-12-01T05:48:31.966772517Z

On a ensuite:
INFO,"Caused by: java.lang.NullPointerException: Cannot invoke ““java.util.Map.get(Object)”” because ““this.m_data.m_groups”” is null

Puis de manière répétée jusquau redémarrage:
ERROR|system|com.simplicite.util.engine.ScriptAgent|callMethod (preLoadGrant)||Exception:Could not initialize class com.simplicite.commons.mla_renault_auth.PlatformHooks||null",2022-12-01T05:48:31.966883177Z

INFO,"java.lang.NoClassDefFoundError: Could not initialize class com.simplicite.commons.mla_renault_auth.PlatformHooks

SIMPLICITE|ERROR||http://mla-api-6ff6c94c9-gccmk:8080||ERROR|system|com.simplicite.util.engine.ScriptAgent|callMethod (preLoadSystemParams)||Exception:Could not initialize class com.simplicite.commons.mla_renault_auth.PlatformHooks||null",2022-12-01T05:48:31.966993751Z
----description of the request----

Steps to reproduce

This request concerns an up-to-date Simplicité instance
and these are the steps to reproduce it:

Technical information

Instance /health
---paste the content of your-instance.com/health---
Simplicité logs
---paste the content of the **relevant** server-side logs---
Browser logs
---paste content of the **relevant** browser-side logs---
Other relevant information

----E.g. type of deployment, browser vendor and version, etc.----

Pour que l’on puise investiguer, merci de nous préciser de quelle version/revision exacte de Simplicité on parle (car il y a, par exemple, de notables différences entre la 5.1 et la 5.2 or je crois me rappeler que vous avez toujours des instances en 5.1).

En outre il faudrait nous fournir le code complet de votre PlatformHooks qui semble être concerné par ces stacktraces

Cela dit, dans votre fichier de logs, je vois surtout de nombreuses traces du genre:

cloudsql-proxy,europe-west1,mla-70907-ope-ext,mla-api-6ff6c94c9-gccmk,irn-70740-ope-ext-2d,k8s_container,ERROR,2022/12/01 06:08:46 Client closed local connection on 127.0.0.1:5432

Je ne connais pas votre infra de déploiement mais ça ressemble fortement à des pbs de connexion à la base de données.

Or, comme tout le paramétrage et le code est chargé depuis la base, si certaines requêtes tombent en erreur faute de connexion, il peut se passer tout et n’importe quoi et les messages qui suivent ne veulent donc rien dire.

Bonjour David,
Nous avons déjà vu ça avec notre DEVOPS:

Il ne s’agit pas des erreurs. Il s’agit plutot des messages d’INFO mais comme cloudsql-proxy est développé en Go, c’est en stderr que les logs standard de Go finissent.
C’est messages d’info c’est pour logger les fermetures/ouvertures des connexions à la bdd

OK mais la première stacktrace qui suit ces messages est java.lang.NoClassDefFoundError: Could not initialize class com.simplicite.commons.mla_renault_auth.PlatformHooks ce qui pourrait potentiellement avoir un lien avec le fait que la plateforme n’a pas pu aller lire en base le code de ce code spécifique…

En tout cas, à nouveau, sans le code complet de votre PlatformHooks on ne peut vraiment pas vous aider.

PS: dans les logs j’ai pu voir que c’est une 5.1.54

1 Like

Hello David, voici le health :

Instance /health

[Platform]
Status=OK
Version=5.1.54
BuiltOn=2022-10-31 15:49
Git=5.1/06cc2793ebaaa50ddf3f3dee2251b397d7bdc09b
Encoding=UTF-8
EndpointIP=10.144.21.118
EndpointURL=http://mla-api-6ff6c94c9-gccmk:8080
TimeZone=Europe/Paris
SystemDate=2022-12-01 15:32:12

[Application]
ApplicationVersion=0.10
ContextPath=
ContextURL=https://api-mla.gke.ope.gcp.renault.com
ActiveSessions=97
TotalUsers=479
EnabledUsers=478
LastLoginDate=2022-12-01 15:25:05

[Server]
ServerInfo=Apache Tomcat/9.0.68
ServerType=WEB
ServerActiveSessions=107

[OS]
Name=Linux
Architecture=amd64
Version=5.10.133+
DockerImageName=centos7
SystemEncoding=UTF-8

[JavaVM]
Version=17.0.5
Vendor=Eclipse Adoptium
VMName=OpenJDK 64-Bit Server VM
VMVersion=17.0.5+8
ScriptEngine=rhino
ScriptEngineVersion=Rhino 1.7.13 2020 09 02
HeapFree=5266102
HeapSize=8716288
HeapMaxSize=14262272
TotalFreeSize=10812086

[Cache]
GrantCache=0
GrantCacheMax=0
GrantCacheRatio=0
ObjectCache=8609
ObjectCacheMax=10000
ObjectCacheRatio=86
ProcessCache=17
ProcessCacheMax=10000
ProcessCacheRatio=0

[Database]
Vendor=3
ProductName=PostgreSQL
ProductVersion=11.13
DriverName=PostgreSQL JDBC Driver
DriverVersion=42.5.0
DBDate=2022-12-01 15:32:12
DBDateOffset=0
DBPatchLevel=5;P01;1aa3e07e98e9b46a7bb1f2d6d409c032
UsingBLOBs=true

[Healthcheck]
Date=2022-12-01 15:32:12
ElapsedTime=12

Et voici le PlatformHooks :

PlatformHooks/java
package com.simplicite.commons.mla_renault_auth;

import com.simplicite.objects.System.Responsability;
import com.simplicite.objects.System.User;
import com.simplicite.util.AppLog;
import com.simplicite.util.Grant;
import com.simplicite.util.GrantHooks;
import com.simplicite.util.GroupDB;
import com.simplicite.util.ModuleDB;
import com.simplicite.util.SessionInfo;
import com.simplicite.util.tools.BusinessObjectTool;
import com.simplicite.util.tools.*;
import com.simplicite.util.*;
import org.json.*;
import java.util.*;

/**
 * Platform Hooks
 */
public class PlatformHooks extends com.simplicite.util.engine.PlatformHooksInterface {
	private static final String DEFAULT_GROUP_ID = GroupDB.getGroupId("MLA_SCOPE_DATA_STEWARD");  // MLA_SCOPE_DATA_STEWARD  MD_READER
	private static final String DEFAULT_MODULE = "ApplicationUsers";  // MLA_SCOPE_DATA_STEWARD  MD_READER
	private static final String DEFAULT_MODULE_ID = ModuleDB.getModuleId(DEFAULT_MODULE);  // MLA_SCOPE_DATA_STEWARD  MD_READER
	private static final String QUERY_W_LICENCE = "select count(distinct(rsp_login_id)) from m_resp r where rsp_activ='1' and rsp_login_id<>2 ;";
	private static final String CHANGEMENT_DE_SCOPE = "CHANGEMENT_DE_SCOPE";

	public boolean isTechnicalLogin(Grant g){
		if(g.isSystemAdmin() || g.getLogin().equals("designer") || g.getLogin().equals("awmla01") || g.getLogin().equals("awmla02") || g.getLogin().equals("awerp04")){
			return true;	
		}
		return false;
	}
	
	@Override
	public void preLoadGrant(Grant g) {
		if(isTechnicalLogin(g)) return;	

		super.preLoadGrant(g);
		try {
			
			SessionInfo info = g.getSessionInfo();
			gestionUtilisateur(g);
			desactivationDesDroits(g);
			ajoutDesDroits(g);
		} catch (Exception e) {
			AppLog.error(GrantHooks.class, "preLoadGrant","Unable to create default rights for " + g.getLogin() + " (" + e.getMessage() + ")", e, null);
		}
	}	
	

	void gestionUtilisateur(Grant g) throws Exception
	{
		Grant systeme = Grant.getSystemAdmin();
		// on récupere les grant de l'utilisateur
		SessionInfo info = g.getSessionInfo();
		if(info ==  null ) { return;}
		JSONObject userinfo = (info.get("userinfo") == null ? null : new JSONObject(info.get("userinfo")));
		if(userinfo ==  null ) { return;}
		String userExists = "select coalesce(count(*),0) from m_user where usr_login = '"+userinfo.getString("uid")+"'";
		User user = (User) systeme.getTmpObject("User");
		if("0".equals(systeme.simpleQuery(userExists)))
		{
			user.resetValues(true);
			user.setFieldValue("usr_login",userinfo.get("uid"));
			user.setFieldValue("usr_lang",info.get("lang"));
			user.setFieldValue("usr_active","1");
			user.setFieldValue("row_module_id",ModuleDB.getModuleId(DEFAULT_MODULE));

			user.setFieldValue("usr_last_name",info.get("lastname"));
			user.setFieldValue("usr_first_name",info.get("firstname"));
			user.setFieldValue("usr_email",info.get("email"));
			user.create();
			
		}
		else{
			user.resetFilters();
			if(user.select(systeme.simpleQuery("select row_id from m_user where usr_login = '"+userinfo.getString("uid")+"'")))
			{
				user.setFieldValue("usr_login",userinfo.get("uid"));
				user.setFieldValue("usr_lang",info.get("lang"));
				user.setFieldValue("usr_active","1");
				user.setFieldValue("row_module_id",ModuleDB.getModuleId(DEFAULT_MODULE));
	
				user.setFieldValue("usr_last_name",info.get("lastname"));
				user.setFieldValue("usr_first_name",info.get("firstname"));
				user.setFieldValue("usr_email",info.get("email"));
				user.save();
			}
		}
	}

	void desactivationDesDroits(Grant g) throws Exception
	{

		Grant systeme = Grant.getSystemAdmin();
		Responsability rsp = (Responsability) systeme.getTmpObject("Responsability");
		if(Tool.isEmpty(Grant.getUserId(g.getLogin()))) { return;}
		rsp.resetValues();
		rsp.resetFilters();
		rsp.setFieldFilter("rsp_login_id",Grant.getUserId(g.getLogin()));
		rsp.setFieldValue("rsp_activ",Tool.TRUE);
		List<String[]> rsps = rsp.search();
		
		// on récupere les grant de l'utilisateur
		SessionInfo info = g.getSessionInfo();
		if(info ==  null ) { return;}
		JSONObject userinfo = (info.get("userinfo") == null ? null : new JSONObject(info.get("userinfo")));
		if(userinfo==null ) {return;}
		JSONArray groups = null;
		if (userinfo.get("role-mla-irn70907") != null) {
			if (userinfo.get("role-mla-irn70907").toString().trim().substring(0,1).equals("[")) {
				groups = (JSONArray) userinfo.get("role-mla-irn70907");
			}else if (userinfo.get("role-mla-irn70907").toString().trim() != null && !userinfo.get("role-mla-irn70907").toString().trim().isEmpty()) {
				if(userinfo.get("role-mla-irn70907").toString().trim().contains(",")){
					groups = new JSONArray(userinfo.get("role-mla-irn70907").toString().trim().split(",")[0]);
				}else{
					groups = new JSONArray();
					groups.put(0,userinfo.get("role-mla-irn70907").toString());
				}
			}	
		}
		
		if(groups ==  null ) { return;}
		List<String> groupsActifs = new ArrayList<String>();
		for(int i=0;i<groups.length();i++) groupsActifs.add(groups.getString(i).toUpperCase());

		for(String[] s : rsps )
		{
			if(s == null) continue;
			rsp.setValues(s);
			if(rsp.getFieldValue("rsp_group_id.grp_name").startsWith("MLA") && groupsActifs.indexOf(rsp.getFieldValue("rsp_group_id.grp_name"))<0)
			{
				//OMI rsp.setFieldValue("rsp_end_dt",Tool.getCurrentDate(1));
				rsp.setFieldValue("rsp_activ",Tool.FALSE);
				String res = rsp.save();
			}
		}	
	}
	
	void ajoutDesDroits(Grant g) throws Exception
	{
		boolean needRefresh = false;
		boolean startNameCondition = g.getLogin().toLowerCase().startsWith("p") || g.getLogin().toLowerCase().startsWith("a");
		if(g!=null && !"public".equals(g.getLogin())) {
			SessionInfo info = g.getSessionInfo();
		
			if(info == null ) { return;}
			JSONObject userinfo = (info.get("userinfo") == null ? null : new JSONObject(info.get("userinfo")));
			if(userinfo ==  null ) {return;}
			JSONArray groups = null;
		    if (userinfo.get("role-mla-irn70907") != null)
		    {
				if (userinfo.get("role-mla-irn70907").toString().trim().substring(0,1).equals("[")) {
					groups = (JSONArray) userinfo.get("role-mla-irn70907");
					
				}else if (userinfo.get("role-mla-irn70907").toString().trim() != null && !userinfo.get("role-mla-irn70907").toString().trim().isEmpty()) {
					if(userinfo.get("role-mla-irn70907").toString().trim().contains(",")){
						groups = new JSONArray(userinfo.get("role-mla-irn70907").toString().trim().split(",")[0]);
					}else{
						groups = new JSONArray();
						groups.put(0,userinfo.get("role-mla-irn70907").toString());
					}
				}	
			}
			if(groups ==  null ) { return;}

			if(Tool.isEmpty(Grant.getUserId(g.getLogin()))) { return;}
			Grant systeme = Grant.getSystemAdmin();
			synchronized (systeme) {
				Responsability rsp = (Responsability) systeme.getTmpObject("Responsability");
				if(Tool.isEmpty(Grant.getUserId(g.getLogin()))) { return;}

				// on desactive tout les groupes 
				String groupAction = ((g != null  && g.getHomeName() != null) ? g.getHomeName().toUpperCase().replace("VIEW","SCOPE") : "" );

				Boolean oneActif = false;
				// on ajoute les droits sur les scope si necessaire
				for(int i=0;i<groups.length();i++)
				{
					rsp.resetValues();
					rsp.resetFilters();
					rsp.setFieldFilter("rsp_group_id", GroupDB.getGroupId(groups.getString(i).toUpperCase()));
					rsp.setFieldFilter("rsp_login_id",Grant.getUserId(g.getLogin()));
//OMI				rsp.setFieldFilter("rsp_activ",Tool.TRUE);
//OMI				rsp.setFieldFilter("rsp_end_dt","is NULL");
					List<String[]> rsps = rsp.search();
					boolean isActif = groups.getString(i).toUpperCase().equals(groupAction);
					
					if(rsps.size()==0)
					{
						Grant.addResponsibility(Grant.getUserId(g.getLogin()),groups.getString(i).toUpperCase(), Tool.getCurrentDate(-1), "", isActif, DEFAULT_MODULE);
					}
				}
			}
		}		
	}	
}
1 Like

Voici la ligne 21 qui est impliquée dans un des stacktrace:

private static final String DEFAULT_GROUP_ID = GroupDB.getGroupId("MLA_SCOPE_DATA_STEWARD");

Je ne pense pas qu’initialiser ainsi une variable statique de cette manière soit une bonne chose, car au moment où cette classe singleton est initialisée, le core cache n’est pas forcément encore chargé. Or la méthode GroupDB.getGroupId va d’bord taper dans le core cache, puis à défaut faisant une requête en base.

On va rendre ça plus robuste (mais je ne sais pas quand ça pourra être livré car la 5.1 n’est normalement plus maintenue depuis fin juin, sachant qu’on a déjà prolongé jusque fin septembre pour laisser le temps aux derniers retardataires de basculer en 5.2).

En tout cas il faudrait surtout refactorer ce code pour valoriser ces constantes à un moment où on est sûr que le core cache est chargé = dans un des hooks “post” du PlatformHooks

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.