Skip to content
Snippets Groups Projects
Commit 604e923e authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

add sonar properties file + some fixes suggested by sonar

parent 6a139364
No related branches found
No related tags found
No related merge requests found
sonar.projectName=MIP Backend - stable
sonar.projectVersion=1.0
sonar.projectKey=mip:backend:stable
sonar.sources=./src/main/java/
\ No newline at end of file
......@@ -149,7 +149,10 @@ public class ExperimentApi {
transaction.commit();
} catch (Exception e) {
transaction.rollback();
if(transaction != null)
{
transaction.rollback();
}
e.printStackTrace();
// 400 here probably
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
......@@ -291,7 +294,10 @@ public class ExperimentApi {
session.getTransaction().commit();
} catch (Exception e) {
// 404 here probably
session.getTransaction().rollback();
if(session.getTransaction() != null)
{
session.getTransaction().rollback();
}
throw e;
}
......@@ -333,7 +339,10 @@ public class ExperimentApi {
transaction.commit();
} catch (Exception e) {
// 404 here probably
transaction.rollback();
if(transaction != null)
{
transaction.rollback();
}
throw e;
}
......@@ -372,7 +381,10 @@ public class ExperimentApi {
transaction.commit();
} catch (Exception e) {
// 404 here probably
transaction.rollback();
if(transaction != null)
{
transaction.rollback();
}
throw e;
}
......@@ -442,7 +454,10 @@ public class ExperimentApi {
// 404 here probably
throw e;
} finally {
session.getTransaction().rollback();
if(session.getTransaction() != null)
{
session.getTransaction().rollback();
}
}
return new ResponseEntity<>(gson.toJson(experiments), HttpStatus.OK);
......
......@@ -21,7 +21,7 @@ public class HibernateUtil {
configuration.getProperties()).build();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
return sessionFactory;
} catch (Throwable ex) {
} catch (RuntimeException ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment