@@ -222,22 +222,25 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
222222 * SQLConf. Additionally, any properties set by set() or a SET command inside sql() will be
223223 * set in the SQLConf *as well as* in the HiveConf.
224224 */
225- @ transient protected [hive] lazy val (hiveconf, sessionState) =
226- Option (SessionState .get())
227- .orElse {
228- val newState = new SessionState (new HiveConf (classOf [SessionState ]))
229- // Only starts newly created `SessionState` instance. Any existing `SessionState` instance
230- // returned by `SessionState.get()` must be the most recently started one.
231- SessionState .start(newState)
232- Some (newState)
233- }
234- .map { state =>
235- setConf(state.getConf.getAllProperties)
236- if (state.out == null ) state.out = new PrintStream (outputBuffer, true , " UTF-8" )
237- if (state.err == null ) state.err = new PrintStream (outputBuffer, true , " UTF-8" )
238- (state.getConf, state)
239- }
240- .get
225+ @ transient protected [hive] lazy val sessionState : SessionState = {
226+ var state = SessionState .get()
227+ if (state == null ) {
228+ state = new SessionState (new HiveConf (classOf [SessionState ]))
229+ SessionState .start(state)
230+ }
231+ state
232+ }
233+
234+ @ transient protected [hive] lazy val hiveconf : HiveConf = {
235+ setConf(sessionState.getConf.getAllProperties)
236+ if (sessionState.out == null ) {
237+ sessionState.out = new PrintStream (outputBuffer, true , " UTF-8" )
238+ }
239+ if (sessionState.err == null ) {
240+ sessionState.err = new PrintStream (outputBuffer, true , " UTF-8" )
241+ }
242+ sessionState.getConf
243+ }
241244
242245 override def setConf (key : String , value : String ): Unit = {
243246 super .setConf(key, value)
0 commit comments