mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 21:05:37 +02:00
[391774] [dstore] NPE if user-log directory cannot be created
This commit is contained in:
parent
4b0b3fbd1b
commit
1e3b02b3c6
1 changed files with 21 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2002, 2011 IBM Corporation. All rights reserved.
|
* Copyright (c) 2002, 2012 IBM Corporation. All rights reserved.
|
||||||
* This program and the accompanying materials are made available under the terms
|
* This program and the accompanying materials are made available under the terms
|
||||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
@ -25,6 +25,7 @@
|
||||||
* Noriaki Takatsu (IBM) - [341578] [dstore] ServerLogger is looped when IOError happens
|
* Noriaki Takatsu (IBM) - [341578] [dstore] ServerLogger is looped when IOError happens
|
||||||
* David McKnight (IBM) - [351993] [dstore] not able to connect to server if .eclipse folder not available
|
* David McKnight (IBM) - [351993] [dstore] not able to connect to server if .eclipse folder not available
|
||||||
* David McKnight (IBM) - [366220] Log_To_File no longer default value for log_location in rsecomm.properties
|
* David McKnight (IBM) - [366220] Log_To_File no longer default value for log_location in rsecomm.properties
|
||||||
|
* David McKnight (IBM) - [391774] [dstore] NPE if user-log directory cannot be created
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.dstore.core.server;
|
package org.eclipse.dstore.core.server;
|
||||||
|
@ -102,19 +103,26 @@ public class ServerLogger implements IServerLogger
|
||||||
if (_logFileStream == null) {
|
if (_logFileStream == null) {
|
||||||
if (logToFile) {
|
if (logToFile) {
|
||||||
try {
|
try {
|
||||||
File _logFile = getLogFile("rsecomm"); //$NON-NLS-1$
|
File _logFile = getLogFile("rsecomm"); //$NON-NLS-1$
|
||||||
if (!_logFile.exists()){
|
if (_logFile != null){
|
||||||
_logFile.createNewFile();
|
if (!_logFile.exists()){
|
||||||
|
_logFile.createNewFile();
|
||||||
|
}
|
||||||
|
if (_logFile != null && _logFile.canWrite()){
|
||||||
|
_logFileStream = new PrintWriter(new FileOutputStream(_logFile));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log_level = 0;
|
||||||
|
logToFile = false;
|
||||||
|
_logFileStream = new PrintWriter(System.out);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (_logFile != null && _logFile.canWrite()){
|
else { // no log file, default to stdout
|
||||||
_logFileStream = new PrintWriter(new FileOutputStream(_logFile));
|
System.out.println("No log file access " + logPathName + "rsecomm.log"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
log_level = 0;
|
||||||
else {
|
logToFile = false;
|
||||||
log_level = 0;
|
_logFileStream = new PrintWriter(System.out);
|
||||||
logToFile = false;
|
}
|
||||||
_logFileStream = new PrintWriter(System.out);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("Error opening log file " + logPathName + "rsecomm.log"); //$NON-NLS-1$ //$NON-NLS-2$
|
System.out.println("Error opening log file " + logPathName + "rsecomm.log"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
log_level = 0;
|
log_level = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue