Torque
  1. Torque
  2. TORQUE-79

TorqueInstance.getConnection should throw an interpretable error message if Torque is not initialized

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 3.3-RC1
    • Fix Version/s: 3.3
    • Component/s: Runtime
    • Labels:
      None

      Description

      From the users mailing list, if Torque.getConection() is called and Torque is not initiialized, the error message is now
      java.lang.NullPointerException: There was no DataSourceFactory configured for the connection XXX
      at org.apache.torque.TorqueInstance.getConnection(TorqueInstance.java:711)
      at org.apache.torque.Torque.getConnection(Torque.java:268)
      at org.apache.torque.util.Transaction.beginOptional(Transaction.java:80)
      at org.apache.torque.util.Transaction.begin(Transaction.java:62)
      .....
      There should be a check whether Torque is initialized, and an exception thrown which says that Torque is not initialized if it is not.

      This issue does not block the release of Torque-3.3-RC2

        Activity

        Hide
        Thomas Vandahl added a comment -

        As far as I can tell, all access to the TorqueInstance goes thru Torque.getInstance(), doesn't it? Wouldn't it be better to place the check there? Maybe one could start initialization automatically, there are places inside Torque where something similar is already done. What do you think?

        Show
        Thomas Vandahl added a comment - As far as I can tell, all access to the TorqueInstance goes thru Torque.getInstance(), doesn't it? Wouldn't it be better to place the check there? Maybe one could start initialization automatically, there are places inside Torque where something similar is already done. What do you think?
        Hide
        Thomas Fox added a comment -

        But Torque,init() also passes through Torque.getInstance(), so if you check there, you cannot initialize any more. Besides, I'd think that one should be able to use Torque without the static facade one day, so I'd rather not put functionality in there.
        What do you mean by "automatic initialization" ? I cannot see from where Torque should guess the db url, username and password ?

        Show
        Thomas Fox added a comment - But Torque,init() also passes through Torque.getInstance(), so if you check there, you cannot initialize any more. Besides, I'd think that one should be able to use Torque without the static facade one day, so I'd rather not put functionality in there. What do you mean by "automatic initialization" ? I cannot see from where Torque should guess the db url, username and password ?

          People

          • Assignee:
            Thomas Fox
            Reporter:
            Thomas Fox
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development